Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The instructions below are for Part 1. Once implemented, submit your solution to InflationRate Part1. If it passes the test cases, move on to InflationRate

The instructions below are for Part 1. Once implemented, submit your solution to InflationRate Part1. If it passes the test cases, move on to InflationRate Part 2. Here is the expected output for InflationRate Part1:

Enter the old and new consumer price indices: 238.170 239.513 Inflation rate is 0.563884

Each lab (InflationRate Part1, InflationRate Part2 and InflationRate Part3) will build successively on the previous submission.

Part 1

Write a program to read in two consumer price indexes and print out the inflation rate.

1. Start with the student starter code and follow the instructions in the code.

2. Instructions to complete are tagged in comments like the ones below. They will always begin with // TODO.

// TODO #1: declare two float variables for the old consumer price index (cpi) and the new cpi

// TODO #2: Read in two float values for the cpi and store them in the variables

// TODO #3: call the function InflationRate with the two cpis

// TODO #4: print the results

3. Once you have this program working, submit for credit.

4. Advance to the next lab InflationRate Part2.

Part 2:

Match the output EXACTLY.

The starter code for this lab is the working code for the previous part1, You may have to create the new directory. If you do not end up in 01_inflationrate_part2, do the following:

user@mimir: ~/2000_csii_sp21/00_inflationrate_part1 > cd .. user@mimir: ~/2000_csii_sp21 > mkdir 01_inflationrate_part2 user@mimir: ~/2000_csii_sp21 > cd 01_inflationrate_part2

To copy the code just do the following (press for filename completion):

user@mimir: ~/2000_csii_sp21/01_inflationrate_part2 > cp ../00/In .

Objective

The goal of the assignment is to take InflationRate part1 and modify it to compute the average of the inflation rates. To do this, add a do-while loop to the code. The loop should stop when the user enters something other than 'y' or 'Y'. Accumulate the inflation rates in a total and keep a count of the valid rates in another variable, then when the program exits the loop, compute the average and print it.

Sample Run

Enter the old and new consumer price indices: 238.343 238.250 Inflation rate is -0.0390204 Try again? (y or Y): y Enter the old and new consumer price indices: 238.250 237.852 Inflation rate is -0.167049 Try again? (y or Y): n Average rate is -0.103035

Part 2

1. Here are the original instructions from Part 1., you will need to keep the original program and modify it.

// TODO #1: declare two float variables for the old consumer price index (cpi) and the new cpi

// TODO #2: Read in two float values for the cpi and store them in the variables

// TODO #3: call the function InflationRate with the two cpis

// TODO #4: print the results

2. Put the logic in parts TODO #2-4 into a do-while loop that asks the user to enter 'y' (or 'Y') if there's more data to be entered. Remember to match the prompt: Try again? (y or Y)

3. Keep a running total of the valid inflation rates and the number of computed rates to calculate the average rate. Assume that if the value returned indicates it's an error for the inputs, it should not be added to the total or included in the average.

4. Print the results after the loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago