Concept explainers
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
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.
// 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
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images
- Write a program that reads in numbers from the user and outputs the information specified below. Part One: Get Valid Input Read in two integers from the user: a lower end of a range and an upper end of a range. Check if the numbers are valid (lower cannot be greater than upper). If the numbers are invalid, use a loop to ask for new numbers. Continue looping until you get two valid values. Part Two: Calculate the Sum Use a loop to calculate the sum of all values from lower (inclusive) to upper (inclusive). Output the sum to the user. Part Three: Analyze the Sum Determine if the sum is even or odd. Determine if the sum is positive, negative, or zero. Output this information to the user. Part Four: Calculate the Average Calculate the average of all numbers in the range from lower (inclusive) to upper (inclusive). Style and Additional Coding Requirements code should compile properly space and indent your code follow Java naming conventions for variables (lower camel case with no…arrow_forwardWrite a program that repeatedly reads an integer value from the keyboard until the user enters a value that is divisible by 3 (it should not read additional values once a value divisible by three has been entered). The program should then output the sum of the values that were NOT divisible by 3. Sample Input 10 4 12 Sample Output 14 Simplifying Assumptions You don't need to (shouldn't) prompt the user for input. You may assume that the user always enters valid integers.arrow_forwardChoose a series (Any series you can find in your math notes or on the internet) and program it to find the solution. The starting and ending points should be input by the user in the program. Use good programming guidelines that we talked in class (clear all, comment lines etc...)...arrow_forward
- The powers of 2 are: 1, 2, 4, 8, 16, 32, .. . Write a program to display the first power of 2, which is bigger than 1000.arrow_forwardCan you use Python programming language to wirte this code? Thank you very much!arrow_forwardUsers don't always provide input as expected. You have asked the user to input an even number. Read in the number the user entered. As long as the number is not even, ignore the input and read in another number. When the input is even, output that number. (Python) Input Format A variable number of odd numbers and then an even number Constraints Input will be whole numbers Output Format Output the even number that was entered Sample Input 0 1 2 Sample Output 0 2 Explanation 0 One is input but it is not even so it is ignored and input is sought again. Two is input, it is even so it is output.arrow_forward
- the output is also missing a few things. this is what he output should look likearrow_forwardCan you use Python programming language to wirte this code? Thank you very much!arrow_forwardStatistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the max and average, respectively. Output the max and average with two digits after the decimal point. Ex: If the input is: 14.25 25 0 5.75 the output is: 25.00 11.25 461710 3116374.qx3zqy7 LAB ACTIVITY 6.7.1: LAB: Varied amount of input data 0/10arrow_forward
- More sophisticated computer-assisted instruction systems monitor the student’s perfor- mance over a period of time. The decision to begin a new topic is often based on the student’s success with previous topics. Write a program that will help an elementary-school student learn multiplication. Use Math.random to produce two positive one-digit integers. To count the number of correct and incorrect responses typed by the student. After the student answers 10 questions, your program should calculate the percentage of correct responses. If the percentage is lower than 75 percent, display Please ask your instructor for extra help, and reset the quiz so another student can try it.arrow_forwardCan someone help me with this program in python? Using this code how can I use the stopwatch module to filll out this table Use the stopwatch module to estimate how long your program runs. stake - initial amount you start with goal - the amount you want to end with (you will either lose it all or make your goal) trials - the number of times you want to run the experiment - run the experiment 100 times to get a more accurate estimate of the probability. Do any empirical analysis using the doubling method. Start with the stake = 500 and goal 1000 and continue to double until the stake = 1000000.arrow_forwardPython Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs the average and max. Ex: If the input is: 15 20 0 5 the output is: 10 20arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education