Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Loop and Text files C++ program name CIS22A-Lab5-XXXXX.cpp You are given an input file numbers.txt that contains some numbers. The first line contains a string.

Loop and Text files

C++ program name CIS22A-Lab5-XXXXX.cpp

image text in transcribed

You are given an input file numbers.txt that contains some numbers.

The first line contains a string.

The rest of the file contains a bunch of integer numbers separated by one or more spaces. You should write the code to read the file data, then calculates and displays the average, the smallest, the largest number. The code also displays the count of numbers that are larger than the average and display the count of numbers that are smaller than the average.

Download the numbers.txt file and save it in the same folder as your CodeBlocks project.

Attention:

1- Do NOT hard-code any absolute file location of the input file inside your code like this

C:\John PC\My Documents\CIS22A\HW umbers.txt

because your code will fail on a PC different than yours.

Put only the file name numbers.txt in the code that opens the file.

Copy this numbers.txt file to your Code Blocks project folder on Windows PC.

If you work on the Mac, you have to use the "trick" presented on my previous lecture to find out which folder you should place the file into.

2- Do not hard-code the count of numbers in your code. Assume that the file can contain any count of numbers after the first string. If your code is well written, it should work without modification when the file contains either 50 numbers or 5000000 numbers. This is the same concept for Microsoft Word that can process your document no matter how large your document is.

3- Use setw() to format the results.

4- Do not use array or any thing that was not presented in class because it is either not needed or bad (like goto statement).

5- The input file has to first opened, processed, and closed to find the average. Then file is opened, processed, and closed again to count of numbers below and above the average.

If the file numbers.txt is not in the current Code Blocks project folder, display a meaningful error message and exit the program:

to use the you work on the on have to use the "trick" presented on my previous lecture to tind out which tolder you to should place the file into. 2- Do not hard-code the count of numbers in your code. Assume that the file can contain any count of numbers after the first string. If your code is well written, it should work without modification when the file contains either 50 numbers or 5000000 numbers. This is the same concept for Microsoft Word that can process your document no matter how large your document is. 3- Use setw() to format the results 4- Do not use array or any thing that was not presented in class because it is either not needed or bad (like goto statement) 5- The input file has to first opened, processed, and closed to find the average. Then file is opened, processed, and closed again to count of numbers below and above the average If the file numbers.txt is not in the current Code Blocks project folder, display a meaningful error message and exit the program: Sample console output: Smallest 50 Largest 25.5099 Average Numbers below the average 499728 Numbers above the average 5000272

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_2

Step: 3

blur-text-image_3

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

What is conservative approach ?

Answered: 1 week ago

Question

What are the basic financial decisions ?

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago