QuestionQuestion

Program 1
Create a file with notepad, called firstLastAge.txt.
Write a
1) 2) 3) 4) 5)
Fred Smith 21 Tuyet Nguyen 18 Joseph Anderson 23 Annie Nelson 19 Julie Wong 17 program that
Open the firstLastAge.txt file
Read the FirstName, LastName and Age. Write a loop to read each line, until eof() Print out the read data
Close the file.

Program 2
Use the file firstLastAge.txt from program 1.
Read in the data and print out the name and age of the youngest person, and also the oldest person.

Program 3
Write a program that asks the user for the number of times to input some first names.
Open a file for output, called savedNames.txt.
Write a loop that reads in the user inputted first names, one at a time, the number of times specified.
Each time a name is entered by the user, write the name to the savedNames file. Close the file.
Look to see if the file was create, and if the names are in it

Program 4
Write a program that the user is prompted for 10 test scores. 0 to 100 points each score.
Open a file for output, called savedTestScores.txt.
Write a loop that prompts the user for the 10 test scores.
Each time a test score is entered by the user, write the test score to savedNames file. And save each test score to an array, called arrayTestScores.
Close the file.
Using the scores stored in the array, write a loop that reads through the array to
determine the minimum, maximum and average test scores. Print out the minimum, maximum and average test scores.
Are the scores written to the file ?

7 Questions
1. How many steps to write to a file
2. How many steps to read from a file
3. What is found in the library <fstream>
4. What is eof()
5. How do you write a string to a file
6. How do you write a char to a file
7. How do you write a line to a file

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;


//Write a program that the user is prompted for 10 test scores. 0 to 100 points each score.
//Open a file for output, called savedTestScores.txt.
//Write a loop that prompts the user for the 10 test scores.
//Each time a test score is entered by the user, write the test score to savedNames file.And save each test score to an array, called arrayTestScores
//Close the file.
//Using the scores stored in the array, write a loop that reads through the array to
//determine the minimum, maximumand average test scores.Print out the minimum, maximumand average test scores.
//Are the scores written to the file ?
//Use filename : Week12YourNameProg3

bool problem4(string outfilename) {
const int numScores = 10; // the number of scores that must be entered by the user
double arrayTestScores[numScores]; // here we will store the array scores . I chose a double as a data type to allow real numbers for the scores, like 87.5

double minimum = 101; // the max value for a score is 100. so we can init the minimum to a value larger that 100
double maximum = -1; // min min value for a score is 0. so we can init the maximum to a value smaller than 0
double average = 0; // this will store the average;
double score;
cout << "Please enter " << numScores << " scores" << endl;
for (int i = 0; i < 10; i++) {...

By purchasing this solution you'll be able to access the following files:
Solution.zip and Solution.docx.

$45.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats