Question

In: Computer Science

1. Write a program that will do file processing. 2. First, create a data file (A7_in.txt)....

1. Write a program that will do file processing.
2. First, create a data file (A7_in.txt). It can contain any number (no fewer than 3) integers, each integer on it’s own line.
3. Your program will read and sum each integer until the EOF.
4. Your program will then find the average of the integers and output the average to another file (A7_out.txt).

c++

Solutions

Expert Solution

#include <iostream>
#include <fstream>
using namespace std;
main() {
 int val[5], sum=0, average=0,list=0;
 ofstream file("result.txt");
 cout << "\t\tSUM AND AVERAGE OF THE NUMBER 1.0";
 cout << "\n\n";
 for ( list=0; list < 5; list++) {
 cout << "Enter Item No. " << list+1 << " : ";
 cin >> list[val];
 }
 cout << "\n";
 cout << "\n List of Values";
 cout << "\n\n";
 for ( list=0; list < 5; list++) {
 sum+=list[val];
 average = (sum/5);
 cout << " " << list[val] << " ";
 }
 cout << "\n\n";
 cout << "\nThe total sum of the values is " << sum << ".";
 cout << "\nThe average of the values is " << average << ".";
 file << "\n\t ======== LIST OF VALUES ========";
 file << "\n\n";
for ( list=0; list < 5; list++) {
 file << " " << list[val] << " ";
 }
 file << "\n";
 file << "\nThe total sum of the values is " << sum << ".";
 file << "\nThe average of the values is " << average << ".";
 file.close();
 cout << "\n\n";
 system("PAUSE");
}
 

Related Solutions

2. Create a java program that reads a file line by line and extract the first...
2. Create a java program that reads a file line by line and extract the first word.        The program will ask for the name of input and output file. Input file: words.txt today tomorrow sam peterson peter small roy pratt Output file: outwords.txt tomorrow peterson small pratt
(Write/read data) Write a Program in BlueJ to create a file name Excersise12_15.txt if it does...
(Write/read data) Write a Program in BlueJ to create a file name Excersise12_15.txt if it does not exist. Write 100 integers created randomly into the file using text I/O. Integers are separated by spaces in the file. Read data back from the file and display the data in increasing order. After writing the file to disk, the input file should be read into an array, sorted using the static Arrays.sort() method from the Java API and then displayed in the...
Using a minimum of 2 classes create a java program that writes data to a file...
Using a minimum of 2 classes create a java program that writes data to a file when stopped and reads data from a file when started. The data should be in a readable format and the program should work in a way that stopping and starting is irrelevant (e.g. all data doesn't have to save just the important elements.) Program should be unique and semi-complex in some way.
Write a java program that can create, read, and append a file. Assume that all data...
Write a java program that can create, read, and append a file. Assume that all data written to the file are string type. One driver class and a class that contains the methods. The program should have three methods as follows: CreateFile - only creating a file. Once it create a file successfully, it notifies to the user that it creates a file successfully. ReadingFile - It reads a contents of the file. This method only allow to read a...
Write a program that creates a concordance. There will be two ways to create a concordance. The first requires a document to be read from an input file, and the concordance data is written to an output file.
Concepts tested by this program            Hash Table,            Link List,hash code, buckets/chaining,exception handling, read/write files (FileChooser)A concordance lists every word that occurs in a document in alphabetical order, and for each word it gives the line number of every line in the document where the word occurs.Write a program that creates a concordance. There will be two ways to create a concordance. The first requires a document to be read from an input file, and the concordance data is written to...
JAVA Assignment: Project File Processing. Write a program that will read in from input file one...
JAVA Assignment: Project File Processing. Write a program that will read in from input file one line at a time until end of file and output the number of words in the line and the number of occurrences of each letter. Define a word to be any string of letters that is delimited at each end by either whitespace, a period, a comma or the beginning or end of the line. You can assume that the input consists entirely of...
Write a Fortran program that is able to read in the data file. The file has...
Write a Fortran program that is able to read in the data file. The file has lines with the structure: 19990122 88888 30.5 Where: i) the first is an 8 digit code with the date: yyyymmdd (yyyy is the year, mm is the month, and dd is the day) ii) the second is the five digit odometer reading of a car iii) the third is the amount of fuel put into the car on that date to fill the tank...
Create this C++ program using classes 1. Create a file text file with a string on...
Create this C++ program using classes 1. Create a file text file with a string on it 2. Check the frecuency of every letter, number and symbol (including caps) 3. Use heapsort to sort the frecuencys found 4. Use huffman code on the letters, symbols or numbers that have frecuencys I created the file, and the frecuency part but i'm having trouble with the huffman and heapsort implementation.
Create a program that creates a sorted list from a data file. The program will prompt...
Create a program that creates a sorted list from a data file. The program will prompt the user for the name of the data file. Create a class object called group that contains a First Name, Last Name, and Age. Your main() function should declare an array of up to 20 group objects, and load each line from the input file into an object in the array. The group class should have the following private data elements: first name ,last...
c++ Create a program that creates a sorted list from a data file. The program will...
c++ Create a program that creates a sorted list from a data file. The program will prompt the user for the name of the data file. Create a class object called group that contains a First Name, Last Name, and Age. Your main() function should declare an array of up to 20 group objects, and load each line from the input file into an object in the array. The group class should have the following private data elements: first name...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT