Question: 134 CSC Programing C++ ONLY LAB 2B Write a program that reads the integers in the text file integers.dat and: 1. Displays the number of

134 CSC Programing C++ ONLY LAB 2B

Write a program that reads the integers in the text file integers.dat and:

1. Displays the number of integers in the file greater or equal to 175 and the number of integers in the file less than 175.

2. Displays the number of even values greater or equal to 175 and number of odd integers greater than 175.

3. Displays the sum of the even integers and the sum of the odd integers as well as the sum of all the integers

4. Displays the largest integer greater or equal to 175 and the smallest integer less than 175.

5. Compute and display the average of the largest and smallest integers found in 4.

Assume the contents of integers.dat (the file is being provided for you) are as follows:

123 475 61 77 910

234 138 134 95 674

345 31 211 952 873

22 7 876 347 450

NOTE:

1. You cannot use arrays to solve this problem.

2. Use two decimal point precision for the average

3. To check your code, adjust one of the integers in the file, recompile your code and run again (suggest changing the largest and smallest integers )

4. Even though there are 20 integers in the file, you should NOT presume there are 20 integers. In other words, you should not solve this problem by declaring 20 integer variables. If I choose to use another integers.dat file other than the one provided with the assignment, your program should still work correctly with that file as well. All you can assume is that a series of integers will be read in from the file. Therefore, you need to implement a solution that uses the repetition control structures (for, while, dowhile) in the reading and processing of these values to produce your output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!