For Exercises 3.16-3.20, perform each of these steps:
- Read the problem statement.
- Formulate the
algorithm using pseudocode and top-down, stepwise refinement. - Write a C
program . - Test, debug and execute the C program.
(Gas Mileage) Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls. Here is a sample input/output dialog:
Learn your wayIncludes step-by-step video
Chapter 3 Solutions
C How to Program (8th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Concepts of Programming Languages (11th Edition)
Starting out with Visual C# (4th Edition)
Starting Out With Visual Basic (7th Edition)
Problem Solving with C++ (9th Edition)
Starting Out with Python (4th Edition)
- (General math) a. Write, compile, and run a C++ program to compute and display the value of the second-order polynomial ax2+bx+c for any user-entered values of the coefficients a, b, c, and the variable x. Have your program display a message to inform users what the program does, and then display suitable prompts to alert users to enter the data. (Hint: Use a prompt such as Enter the coefficient of the x-squared term:.) b. Check the result of your program written for Exercise 7a by using the following test data: Testdataset1:a=0,b=0,c=22,x=56Testdataset2:a=0,b=22,c=0,x=2Testdataset3:a=22,b=0,c=0,x=2Testdataset4:a=2,b=4,c=5,x=2 After finishing your verification, use your program to complete the following chartarrow_forwardwrite the pseudocode solution of the following exercises: a. Read two numbers, multiply them together and print out their product. b. Ask the user for a distance in miles and convert it to kilometers. Display the result (1 mile = 1.6 kilometers). c. Ask the user for his/her birth date and calculate and display the age of the user. d. Perform the following: i. Read in 5 separate numbers. ii. Calculate the average of the five numbers.arrow_forwardLanguage: C++ (Apartment problem) A real estate office handles , say, 50 apartment units. When the rent is, say, $600 per month, all the units are occupied. However, for each, say $40 increase in rent, one unit becomes vacant. Moreover, each occupied unit requires an average of $27 per month for maintenance. How many units should be rented to maximize the profit? Write a program that prompts the user to enter: The total number of units. The rent to occupy all the units. The increase in rent that results in a vacant unit. Amount to maintain rented unit. The program then outputs the number of units to be rented to maximize the profit. Note: Please include the pseudocodearrow_forward
- 1.20 Give one example of a logic error in a program, using the language of your choice.arrow_forwardExercise 15 Given the radius, in inches, and price of a pizza, design an algorithm to find the price of the pizza per square inch. You may assume that the value of π = 3.141593. In your program, declare a named constant PI to store this value. Below is an example of how the completed program should work:arrow_forwardFlow Chart Algorithm 2.You want badly to take a friend out for a movie and dinner. And guess what? Your friend gladly accepted but you are broke. Now you have 36 hours (3 days) to get $100 and avoid embarrassment. Your sources are a last minute neighbor's mow yard, parents, relatives, or else.arrow_forward
- State which of the following are true and which are false. If a statement is false, explain why.a) Experience has shown that the most difficult part of solving a problem on a computeris producing a working C program.b) A sentinel value must be a value that cannot be confused with a legitimate data value.c) Flowlines indicate the actions to be performed.d) Conditions written inside decision symbols always contain arithmetic operators (i.e., +,-, *, /, and %).e) In top-down, stepwise refinement, each refinement is a complete representation of thealgorithm.arrow_forwardComputer Fundamentals and Programming 2 Problem 2: Given two number for the variables A and B, create a program that would: A. print the sum of A and B B. print the average of A and B, if the sum is greater than 100 C. print the product of A and B, if the sum is less than or equal to 100.arrow_forwardWrite the code in python programming for the below problem. Introduction One useful data point in detecting fraud is the account history of a customer. For an account, we receive notification of purchases and, sometimes, reports of fraud. Typically, a prior report of fraud for an account would increase the perceived risk of fraud on future transactions. Similarly, a history of non-fraudulent purchases for an account would decrease the risk of fraud. A credit card holder has 90 days to report any fraudulent transactions with the card. So if an account has purchases over 90 days old and no reports of fraud, we assume that these older purchases were not-fraudulent. Problem Description The purpose of this programming problem is to determine the status of a customer account history at the time a new purchase is made. The input is a sequence of customer account events, in chronological order. Each event has three fields, all of which are of string type ,, For example:…arrow_forward
- (General math) Modify the program written for Exercise 2 so that it accepts the x- and y-coordinates of two points. Have your program determine and display the midpoints of the two points (using the formula given in Exercise 2). Verify your program by using the following test data: Testdataset1:Point1=( 0,0)andPoint2=( 16,0)Testdataset2:Point1=( 0,0)andPoint2=( 0,16)Testdataset3:Point1=( 0,0)andPoint2=( 16,0)Testdataset4:Point1=( 0,0)andPoint2=( 0,16)Testdataset5:Point1=( 5,5)andPoint2=( 5,5) When you have finished your verification, use your program to complete the following chart:arrow_forwardComputer Science Please help You went camping overnight but forgot to take with you a heater and need to make one using a dc battery of V0 and spare electrical wires of different lengths and resistivity. The battery has lead with the resistance of Rw. Please obtain the formula for the joule heat power and plot it as a function of RH ( in MATLAB) and in comparison to the resistance of the connecting leads, Rw. (Note: express RH = x Rw, where x is the effective ratio; vary x and plot Pmax vs. x). and Find the heating power if the heater is made out of superconducting metal. Will this heater work and why?! What is to happen on the molecular ( i.e. electron) level ?!arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning