Computers and Technology

Convert MPG Algorithm to C++ code. Activity:
1. Understand the MPG Algorithm posted in this activity.
2. Determine the condition for terminating the loop.
3. Which step will cause infinite loop if we took it out.
4. Implement provided algorithm in C++ code
5. Define possible sample inputs and output (test cases) to cover each steps in this algorithm (For example, you need to have two different input sets in order to have Step 8 and 9 both covered.
6. Enhance the algorithm and write code to calculate the accumulated mpg from multiple trips.
Reference:
Step Operation
1 response = Yes
2 While (response = Yes) do Steps 3 through 11
3 Get values for gallons used, starting mileage, ending mileage
4 Set value of distance driven to (ending mileage - starting mileage)
5 Set value of average miles per gallon to (distance driven = gallons used)
6 Print the value of average miles per gallon
7 If average miles per gallon > 25.0 then
8 Print the message 'You are getting good gas mileage
Else
9 Print the message You are NOT getting good gas mileage'
10 Print the message 'Do you want to do this again? Enter Yes or No'
11 Get a new value for response from the user
12 Stop
Submit the Discussion Response with code and execution result.
Part 2. Analyzes each sentence and state your reasoning on applicability to your lab assignments (150 words) and example to support the statement below:
1. Functions break large computing tasks into smaller ones and enable people to build on what others have done instead of starting over from scratch.
2. Appropriate functions hide details of operation from parts of the program that don’t need to know them, thus clarifying the whole, and easing the pain of making changes "

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 21:00, tiffg2588
Will this setup result in what kathy wants to print?
Answers: 2
image
Computers and Technology, 24.06.2019 02:10, ttangelique
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, minecrafter3882
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe what
Answers: 1
image
Computers and Technology, 24.06.2019 16:30, kjhgfcvb5761
The database design steps are listed below in the incorrect order. choose the correct order number next to each step. determine the information to be stored in the database. determine the fields needed to record the data determine if there will be any repetition of data entered, and separate the fields into tables to normalize the data. create relationships to connect the tables.
Answers: 3
Do you know the correct answer?
Convert MPG Algorithm to C++ code. Activity:
1. Understand the MPG Algorithm posted in this...

Questions in other subjects: