Question
Can someone please help me with this in C++, I have been working on this for more than 6 hours straight and am so close
Can someone please help me with this in C++, I have been working on this for more than 6 hours straight and am so close to finishing, but I can't seem to figure out how to do the last part of this assignment. I have every other part down, I just need to figure out how to get the average. I thought I could divide by 2 because you're only using 2 values, but when I submit it to my online grader, it works all but for the last line, the average. The average gives me an entirely different number and I'm not sure why. This is due Saturday, Feb 11, I appreciate any help, thank you.
These are the instructions:
This is what I have for my code:
And this is what the online grader is showing me after I submit it:
Thanks again
InfationRate Part1 This is a 2 part project. The instructions below are for Part 1 . Once implemented, submit your solution to InflationRate Partl. If it passes the test cases, move on to InflationRate Part 2. Here is the expected output for InflationRate Partl: Enter the old and new consumer price indices: 238.170239.513 Inflation rate is 0.563884 Each lab (InflationRate Part1, InflationRate Part2 and InflationRate Part3) will build successively on the previous submission. 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 br // 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 (next page). Additional Test Cases - Test for positive inflation rate Enter the old and new consumer price indices: 226.655227.663 Inflation rate is 0.444727 - Test for negative inflation rate Enter the old and new consumer price indices: 230.085229.815 Inflation rate is 0.11735 - Test for old CPI negative input Enter the old and new consumer price indices: 230.085229.815 Inflation rate is 0 - Test for new CPI negative input Enter the old and new consumer price indices: 230.085229.815 Inflation rate is 0 - Test for old CPI zero input Enter the old and new consumer price indices: 0.0001 Inflation rate is 0 Note: Remember that cin reads the number until it sees a whitespace or non-numeric character. Newline is interpreted the same as space. InflationRate Part2 This lab is Part 2 of a 2 Part Lab called InflationRate. Please complete the instructions. Here is sample output for one run of the program when it's complete. Match the output EXACTLY. Enter the old and new consumer price indices: 238.343238.250 Inflation rate is 0.0390204 Try again? (y or Y) : y Enter the old and new consumer price indices: 238.250237.852 Inflation rate is 0.167049 Try again? (y or Y):n Average rate is 0.103035 1. Here are the original instructions from Part 1. // 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 TODO \#2-4 into a loop that asks the user to enter ' y ' (or ' Y ) if there's more data to be entered. 3. Keep a running total of the valid inflation rates and the number of computed rates to calculate the average rate. 4. Print the results after the loop Additional Test Cases - Multiple odd number test cases 238.343y238.250y237.852n238.250237.852238.031 - Multiple even number test cases 237.805y238.638y238.654y238.316n238.638238.654238.316237.945 - Multiple negative inputs 237.805y238.638y238.654y238.316y237.945y238.316n238.638238.654238.316237.945237.945237.945 - Multiple zero inputs [bahn1estorm lab1] $./a. out Enter the old and new consumer price indices: 238.343238.250 Inflation rate is 0.0390204 Try again? ( y or n):y Enter the old and new consumer price indices: 238.250237.852 Inflation rate is 0.167049 Try again? ( y or n):n Average inflation rate is 0.103035 [bahn1estorm lab1] $ Actual Output Output: 1 Enter the old and new consumer price indices: Inflation rate is 0.0390204 2 Try again? ( y or n ) : Enter the old and new consumer price indices: Inflation rate is 0.167049 3 Try again? ( y or n ) : Enter the old and new consumer price indices: Inflation rate is o.0752572 4 Try again? ( y or n ) : Average inflation rate is 0.0277776 Enter the old and new consumer price indices: Inflation rate is 0.35029 Try again? ( y or n ): Enter the old and new consumer price indices: Inflation rate is 0.00670743 Try again? ( y or n ) : Enter the old and new consumer price indices: Inflation rate is 0.141633 Try again? ( y or n ) : Enter the old and new consumer price indices: Inflation rate is - 0.15567 Try again? ( y or n ): Average inflation rate is 0.0479878 Enter the old and new consumer price indices: Inflation rate is 0.141633 Try again? ( y or n ) : Enter the old and new consumer price indices: Error: CPI values must be greater than 0 Enter the old and new consumer price indices: Inflation rate is 0.15567 Try again? ( y or n ): Enter the old and new consumer price indices: Error: CPI values must be greater than 0 Enter the old and new consumer price indices: Inflation rate is 0 Try again? ( y or n ): Average inflation rate is 4.28818e+23Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started