Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 2, Problem 12PP
Program Plan Intro
Water well
Program Plan:
- Include required header files.
- Define main function.
- Initializes the values of gallons per cubic foot to “7.48” using “const” modifier.
- Initializes the value of pi to “3.1415” using “const” modifier.
- Declare “int” variable for radius.
- Declare “double” variables for radius feet, depth, volume of well and gallons value.
- Create the prompt statement for radius and depth of well.
- Read the value of radius and depth from user.
- Convert the radius in inches to feet using “radius / 12.0”.
- Compute the volume of well in cubic feet using “(PI * radius_Feet * radius_Feet) * depthValue”.
- Convert the volume of well to gallons of water using “volume * GALLONS_PER_CUBIC_FOOT”.
- Final display the gallons of water for given well holds.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Let l be a line in the x-yplane. If l is a vertical line, its equation is x = a for some real number a.
Suppose l is not a vertical line and its slope is m. Then the equation of l is y = mx + b, where b is the y-intercept.
If l passes through the point (x₀, y₀), the equation of l can be written as y - y₀ = m(x - x₀).
If (x₁, y₁) and (x₂, y₂) are two points in the x-y plane and x₁ ≠ x₂, the slope of line passing through these points is m = (y₂ - y₁)/(x₂ - x₁).
Instructions
Write a program that prompts the user for two points in the x-y plane. Input should be entered in the following order:
Input x₁
Input y₁
Input x₂
The language for coding must be in python
Neural Network Units
Implement a single sigmoid neural network unit with weights of [-1.2, -1.1, 3.3, -2.1]
Calculate the outputs for two training examples:Example 1: [0.9, 10.0, 3.1, 1]Example 2: [0.9, 2.1, 3.7, 1]
Note that you don't have to explicitly include a threshold or bias since the examples include a last element of 1 which means that the last weight effectively operates as a threshold.
Assuming that a sigmoid unit response >0.5 denotes a positive class and <0.5 is negative class, is example 1 positive or negative? is example 2 positive or negative?
Create a single ReLU unit and provide the outputs for those examples.
Calculate the derivative of the sigmoid with respect to net input for both examples
Calculate the derivative of the ReLU with respect to net input for both examples
A library must build shelving to shelve 200 4-inch high books, 150 8-inch high books, 300 10-inch high books and 180 12-inch high books. Each book is 0.5 inch thick. The library has several ways to store the books. For example, an 8-inch high shelf may be built to store all books of height less than or equal to 8 inches, and a 12-inch high shelf may be built for the 12-inch books. Alternatively, a 12-inch high shelf might be built to store all books. The library believes it costs $2,300 to build a shelf and that a cost of $5 per square inch is incurred for book storage. (Assume that the area required to store a book is given by height of storage area times book’s thickness.) Formulate and solve a shortest-path problem that could be used to help the library determine how to shelve the books at minimum cost. (Hint: Have nodes 0, 4, 8, 10 and 12, with cij being the total cost of shelving all books of height >i and ≤ j on a single shelf.)
Chapter 2 Solutions
Problem Solving with C++ (9th Edition)
Ch. 2.1 - Give the declaration for two variables called feet...Ch. 2.1 - Give the declaration for two variables called...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Give a C++ statement that will increase the value...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Prob. 6STECh. 2.1 - Prob. 7STECh. 2.2 - Give an output statement that will produce the...Ch. 2.2 - Give an input statement that will fill the...Ch. 2.2 - Prob. 10STE
Ch. 2.2 - Write a complete C++ program that writes the...Ch. 2.2 - Write a complete C++ program that reads in two...Ch. 2.2 - Prob. 13STECh. 2.2 - Write a short program that declares and...Ch. 2.3 - Convert each of the following mathematical...Ch. 2.3 - Prob. 16STECh. 2.3 - What is the output of the following program lines...Ch. 2.3 - Write a complete C++ program that reads two whole...Ch. 2.3 - Given the following fragment that purports to...Ch. 2.3 - What is the output of the following program lines...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Suppose savings and expenses are variables of type...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Consider a quadratic expression, say x2 x 2...Ch. 2.4 - Consider the quadratic expression x2 4x + 3...Ch. 2.4 - What is the output of the following cout...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What output would be produced in the previous...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the most important difference between a...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - Write a complete C++ program that outputs the...Ch. 2.5 - The following if-else statement will compile and...Ch. 2.5 - Prob. 36STECh. 2.5 - Write a complete C++ program that asks the user...Ch. 2 - A metric ton is 35,273.92 ounces. Write a program...Ch. 2 - The Babylonian algorithm to compute the square...Ch. 2 - Many treadmills output the speed of the treadmill...Ch. 2 - Write a program that plays the game of Mad Lib....Ch. 2 - The following is a short program that computes the...Ch. 2 - A government research lab has concluded that an...Ch. 2 - Workers at a particular company have won a 7.6%...Ch. 2 - Modify your program from Programming Project 2 so...Ch. 2 - Negotiating a consumer loan is not always...Ch. 2 - Write a program that determines whether a meeting...Ch. 2 - Prob. 6PPCh. 2 - It is difficult to make a budget that spans...Ch. 2 - You have just purchased a stereo system that cost...Ch. 2 - Write a program that reads in ten whole numbers...Ch. 2 - Modify your program from Programming Project 9 so...Ch. 2 - Sound travels through air as a result of...Ch. 2 - Prob. 12PPCh. 2 - The HarrisBenedict equation estimates the number...Ch. 2 - Write a program that calculates the total grade...Ch. 2 - It is important to consider the effect of thermal...
Knowledge Booster
Similar questions
- The language must be in python. Neural Network Units weights of [-1.2, -1.1, 3.3, -2.1] two training examples:Example 1: [0.9, 10.0, 3.1, 1]Example 2: [0.9, 2.1, 3.7, 1] Note that you don't have to explicitly include a threshold or bias since the examples include a last element of 1 which means that the last weight effectively operates as a threshold. Create a single ReLU unit and provide the outputs for those examples. Calculate the derivative of the sigmoid with respect to net input for both examples Calculate the derivative of the ReLU with respect to net input for both examplesarrow_forwardYou and your friends decided to hold a “Secret Santa” gift exchange, where each person buys a gift for someone else. To see how this whole thing works, let’s consider the following example. Suppose there are 7 people A, B, C, D, E, F, and G. We denote x → y to mean “x gives a gift to y.” If the gift exchange starts with person A, then they give a gift to E. Then E gives a gift to B. And it is entirely possible that B gives a gift to A; in such a case we have completed a “cycle.” In case a cycle occurs, the gift exchange resumes with another person that hasn’t given their gift yet. If the gift exchange resumes with person D, then they give a gift to G. Then G gives a gift to F. Then F gives a gift to C. Then finally C gives a gift to D, which completes another cycle. Since all of the people have given their gifts, the giftexchange is done, otherwise the gift exchange resumes again with another person. All in all, there are two cycles that occurred during the gift exchange: A → E → B → A…arrow_forwardA Norman window has the shape of a rectangle surmounted by a semicircle. Suppose the outer perimeter of such a window must be 600 cm. In this problem you will find the base length x which will maximize the area of such a window. Use calculus to find an exact answer. When the base length is zero, the area of the window will be zero. There is also a limb on how large x can her when x is large enough, the rectangular portion of the window shrinks down to zero height. What is the exact largest value of x when this occurs?arrow_forward
- Even the tiniest activities may be made easier using the Spiral Model.arrow_forward. Draw the ERD for the following scenario. In a university, a Lecturer can teach many different courses and even the same course numerous times. Courses can also be taught by many lecturers. A student is enrolled in only one program but a program can contain many students. Students can be rolled in many courses at the same time and the courses have many students enrolled.arrow_forwardRecall Pigou’s example discussed in class, where there are two roads that connect a source, s, and destination, t. The roads have different travel costs. Fraction x1 of the traffic flow on route 1, and the remainder x2 on route 2. Here consider the following scenario. • The first road has “infinite” capacity but is slow and requires 1 hour travel time, T1 = 1. • The second road always requires at least 15 mins, which then increases as a function of traffic density, T2 = 0.25 + 0.75x2. If drivers act in a “selfish” manner – the user optimal scenario – all the traffic will flow on the second path, as one is never worse off. Worst case scenario for path 2, both paths take one hour. So no one is incentivized to change their behavior. 1. Assume user optimal behavior, and calculate τ the expected travel time per car. 2. If instead we could control the flows, we could minimize the expected travel time. Using the expression in part (a), calculate the optimal allocation of flows x¯1 and ¯x2…arrow_forward
- Conditions:1. Water must be replaced when -Water level (T) < 41 mm -Discard water and fill 30% of Aquarium water volume when high Acidic pH (pH> 9)2. Fish food (pellets): 1 x 4.5 mL/day at 6am in the morning, the machine only contains 100 mL (warning on D-day is over)3. To save electricity, the aquarium lights are on at night (8 hours) How to make proven simulation aquarium automatic care in tinkercad with Arduino (include code simulation in tinkercad) based on above conditions?arrow_forwardHow make simulation Aquarium Automatic Care (AOC) system (incl. coding) with Arduino. AOC is simulated using Tinkercad based on below conditions? Conditions: 1. Water must be replaced when -Water level (T) < 41 mm -Discard water and fill 30% of Aquarium water volume when high Acidic pH (pH> 9)2. Fish food (pellets): 1 x 4.5 mL/day at 6am in the morning, the machine only contains 100 mL (warning on D-day is over)3. To save electricity, the aquarium lights are on at night (8 hours)arrow_forwardThe Harvard robotics club has organized a Robothon. n robots are placed alongthe edge of a circular area at the middle of the OAT(open air theatre). Each robot will move along arbitrary tracksinside the circle while leaving behind a heat signature along its trail. However, they have beenprogrammed not to cross their own trail or the trail of another robot, neither will they ever moveout of the circle. In case a pair of robots i and j meet at any point, they are removed from the sceneand the club will pay a reward sum of M[i, j] to the owners of these robots. Note that some robotscan keep moving infinitely without ever meeting another one. Given the reward matrix M whereM[i, j] = M[j, i], design a polynomial time algorithm that determines the maximum money theclub might potentially end up spending. For this particular problem, give a very brief justificationof the recurrence. Give pseudo-code for a dynamic program which solves the recurrence efficiently Youdo not need to prove…arrow_forward
- In practical life, the employees get salaries and pay taxes honestly. Sometimes, the process of drawing salariesand payment of taxes may lead to some interesting situation. Suppose, a person draws salary of Rs. 10,000 permonth. A certain percentage of tax is charged on that amount, which is deducted every month. But if the salaryof the person is more than Rs. 10,000 per month, then the tax rate is different. Similarly if a person is getting Rs.20,000 per month, he/she would be charged more under a different tax rate slab. The interesting situationdevelops if there is an anomaly in the tax rates i.e. a person who is getting higher salary takes home lesser moneyas compared to the other person with less gross salary.To further elaborate it, we suppose that there is company 'C' where 100 or less than 100persons are employed. The salaries of the employees and their tax rates are known to us.We are required to list those unlucky persons, who are getting lesser take-home salary(net salary)…arrow_forwarda). The classical Tower of Hanoi (ToH) puzzle is well-known. It consists of three pegs and disks of sizes 1,2, . . . , n arranged on one of the pegs as a “tower”, in decreasing order of size, from bottom to top. The goal of the puzzle is to transfer all disks to another peg, placed in the same order. At each step, a single disk is moved from (the top of) one peg to (the top of) another, subject to the “divine” rule: to never have a larger disk above a smaller one. Write an algorithm ad draw the flow chart for moving all the disks from Peg A to Peg C. b). Write an algorithm and draw a flow chart for a software solution that can solve the equation below problem. Where ai = {a1,a2,a3,...an} marksarrow_forwardA materials engineer wants to study the effects of two different processes for sintering copper (aprocess by which copper powder coalesces into a solid but porous copper) on two different typesof copper powders. From each type of copper powder, she randomly selects two samples andthen randomly assigns one of the two sintering processes to each sample by the flip of a coin.The response of interest measured is the porosity of the resulting copper. Explain what type ofstudy this is and why.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks ColeC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning