Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 2 ( 9 marks ) Let ( money . txt ) be a text file that contains amounts of money spent on clothes. Assume

Program 2(9 marks)
Let (money.txt) be a text file that contains amounts of money spent on clothes. Assume the num-
ber of values stored in the file in unknown. Write a complete C++ program that reads the money
amounts from the text file and outputs the following information to the console:
The number of values stored in the file
The number of money amounts that are in the interval [0,30)
The number of money amounts that are in the interval [30,60)
The number of money amounts that are in the interval [60,)
Example: if the values stored in the file are: 35408015106445393627141824293134,
then your program should print out:
The number of values stored in the file is 18
The number of money amounts that are in the interval [0,30) is 10
The number of money amounts that are in the interval [30,60) is 7
The number of money amounts that are in the interval [60,) is 1
Note: test if the text file is opened correctly.
Hint: use a while loop.
Question on Program 2: (1 Mark)
Briefly explain what would be changed if we were to output the information to a text file instead
of the console?
image text in transcribed

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

More Books

Students also viewed these Databases questions

Question

Evaluate lim(xn/(1 + xn)) for x R, x > 0.

Answered: 1 week ago