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 Plus Mylab Programming With Pearson Etext -- Access Card Package (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) The value of p can be approximated by this series: 4(113+1517+....) Using this formula, write a program that calculates and displays the value of , using 2, 3, and 4 terms of the series.arrow_forwardQuestion-1 Friend's Party Circle: There are a few friends living in the same area. They have a party every weekend and the place of party change each week. It is always a difficult task to select a place which is nearest for everyone. They all decided advantage of Computer Science to solve this problem. to take Names of friends are Ahmed, Rehman, Careem, Basit, Dawood, Ghani, and Farid. Ahmed lives at 5 minutes’walk from rehman and at 10 minutes' walk from Careem. Careem lives at 3 minutes' walk from Dawood. Rehman lives at 4 minutes' walk from Basit and 2 minutes' walk from Dawood. Dawood lives at two minutes' walk from Farid. Ghani lives at 2 minutes' walk from Basit. b. In above directed graph G. You are required to devise an algorithm to find all possible paths.arrow_forwardQuestion 4 - Algorithm Design Imagine you are a treasure hunter standing at one side of the river. There are n (a positive integer) stones on the river. They are aligned on a straight line and at the nth stone, there is treasure waiting for you. Your target is to reach the nth stone. For each move, you have the choice of either walking (move one stone ahead) or leaping (move two stones ahead). Also, you are not allowed to travel backwards. Design an algorithm that calculates the number of ways (sequences of walks/leaps) that get you to the treasure stone. You should clearly explain the algorithm and demonstrate the correctness of the algorithm with a complete proof. Here is an example. For n = 1 5, there are 8 ways: Method 1: walk → walk → walk → walk → walk Method 2: walk → walk → walk → leap Method 3: walk → walk → leap → walk Method 4: walk → leap → walk → walk walk Method 5: leap → walk → walk → Method 6: leap → leap walk Method 7: leap → walk → leap Method 8: walk → leap leaparrow_forward
- c program with algorithm and flowchart to calculate the energy bill. read the starting and ending meter reading.the charges are as follows no; of units consumed - rate in rupees 1.) 200-500 3.50 2.)100-200 2.50 3.) 0-100 1.50arrow_forwardnote: For SITUATION, create a program that solves the problem. For PERFORM/ANSWER, explain or answer it with essayarrow_forwardA well-designed algorithm should be free of ambiguity." briefly describearrow_forward
- Algorithms and data examples to be written: Problem 1: (Hint: Use a sequential structure) How do you calculate the miles you are getting per gallon of gasoline if you record the mileage readings from your car's odometer each time you fill up the gas tank? Two odometer readings should be inputted, one reading is before you fill up the gas tank, and the second reading is when you refill the gas tank. The third input is the quantity of gallons of gasoline purchased when the gas tank is refilled. After inputting these 3 values, calculate and output: The miles traveled between gas refills The average miles per gallon based on the miles traveled and the amount of gasoline purchased after the time the gas tank is refilled a. b. Algorithm: Data Example: Problem 2: (Hint: Use a sequential structure) How do you calculate the price you would pay for an item if it is on sale and you have an additional discount coupon? To calculate the final price paid, 3 inputs are needed: the original price of…arrow_forward1. Make an algorithm for the given program 2. Illustrate a Flowchartarrow_forwardExercises: 1. Develop a flow-chart to print the square of all numbers from 0 to 10arrow_forward
- Identify which type of algorithmic operation each one of the following steps belongs to a Get a value for x from the user. b. Test to determine if x is positive. If not, tell the user that he or she has made a mistake. c. Take the cube root of x. d. Do Steps 1.1, 1.2, and 1.3 x times.arrow_forwardMultiple Choice 1 Which of the following statements is true about the difference between while looping and do..while looping? a) while loops require brackets to be syntactically correct b) only do while loops require a condition c) while loops must mutate a variable in order to break d) do while loops ensure that the body executes at least oncearrow_forwardDo 3rd CSE PYTHON programs: 1. Program to Check Whether a Given Year is a Leap Year2. Program to Read Height in Centimeters and then Convert the Height to Feet and Inches3. Program to Take the Temperature in Celcius and Covert it to Farenheit4. Program to Compute Prime Factors of an Integer5. Program to Generate all the Divisors of an Integer6. Program to Print Table of a Given Number7. Program to Print Sum of Negative Numbers, Positive Even Numbers and Positive Odd numbers in a List8. Program to Print Largest Even and Largest Odd Number in a List9. Program to Find Those Numbers which are Divisible by 9 and Multiple of 3 in a Given Range of Numbers10. Program to Check if a Number is an Armstrong Number11. Program to Print the Pascal's triangle for n number of rows given by the user12. Program to Check if a Number is a Perfect Number13. Program to Check if a Number is a Strong Number14. Program to Find the LCM of Two Numbers15. Program to Find the GCD of Two Numbersarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr