1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
snow_lady [41]
3 years ago
12

Exercise 4: Bring in program grades.cpp and grades.txt from the Lab 10 folder. Fill in the code in bold so that the data is prop

erly read from grades.txt. and the desired output to the screen is as follows: OUTPUT TO SCREEN DATAFILE Adara Starr has a(n) 94 average Adara Starr 94 David Starr has a(n) 91 average David Starr 91 Sophia Starr has a(n) 94 average Sophia Starr 94 Maria Starr has a(n) 91 average Maria Starr 91 Danielle DeFino has a(n) 94 average Danielle DeFino 94 Dominic DeFino has a(n) 98 average Dominic DeFino 98 McKenna DeFino has a(n) 92 average McKenna DeFino 92 Taylor McIntire has a(n) 99 average Taylor McIntire 99 Torrie McIntire has a(n) 91 average Torrie McIntire 91 Emily Garrett has a(n) 97 average Emily Garrett 97 Lauren Garrett has a(n) 92 average Lauren Garrett 92 Marlene Starr has a(n) 83 average Marlene Starr 83 Donald DeFino has a(n) 73 average Donald DeFino 73

Computers and Technology
1 answer:
Alex73 [517]3 years ago
3 0

Answer:

Here is the C++ program:

#include <fstream>  //to create, write and read a file

#include <iostream>  // to use input output functions

using namespace std;  //to access objects like cin cout

const int MAXNAME = 20;  //MAXNAME is set to 20 as a constant

int main(){  //start of main() function

ifstream inData;  //creates an object of ifstream class

inData.open("grades.txt");  //uses that object to access and opens the text file using open() method

char name[MAXNAME + 1];   // holds the names

float average;   //stores the average

inData.get(name,MAXNAME+1);  //Extracts names characters from the file and stores them as a c-string until MAXNAME+1 characters have been extracted

while (inData){  //iterates through the file

 inData >> average;  //reads averages from file using the stream extraction operator

 cout << name << " has a(n) " << average << " average." << endl; //prints the names along with their averages

 inData.ignore(50,'\n');  //ignores 50 characters and resumes when  new line character is reached. It is used to clear characters from input buffer

 inData.get(name,MAXNAME+1);}  //keeps extracting names from file

return 0; }

Explanation:  

The program is well explained in the comments added to each line of the code. The program uses fstream object inData to access the grades.txt file. It gets and extracts the contents of the file using get() method, reads and extracts averages from file using the stream extraction operator. Then program displays the names along with their averages from grades.txt on output screen.

The grades.txt file, program and its output is attached.

You might be interested in
If a driver who is under the age of 21 is stopped by a law enforcement officer and shown to have a BAL of .02 or greater, he or
n200080 [17]
Its actually BAC (clood Alchohol Content) and  it dependsn on what state you live in, and usually first time offenders with a BAC over 0.15 will have their license suspended for 90 days. but again it depends on the state. and anything below a 0.08% will just result in a warning but what state is it?
5 0
4 years ago
Which is true about routers and switches?
Julli [10]

Answer:

Routers control traffic between networks while switches control traffic within a network

Explanation:

There are different devices involves in computer networking. These devices include hub, switch, router and other components.

Switch is used to connect the computer with in the network. It controls the traffic between different computers within the network. Different computers are connected with each other through different cables with the help of switch.

On the other hand, different LAN's connected through the cable with a router to communicate with each other. This device is used to control the traffic between different networks.

 

8 0
3 years ago
Which are factors that go into a project plan?
BaLLatris [955]

Answer:

The four critical factors to planning a successful project

Explanation:

5 0
3 years ago
Sukhi needs to insert a container into her form to collect a particular type of information.
Hunter-Best [27]

Answer:

text box

Explanation:

on edge 2020

6 0
4 years ago
Which of the following statements is not true about the TCP opening and closing of connections?
lubasha [3.4K]

Answer:  c.)

Explanation:

The bit SYN is used in order to synchronize segment numbers in the sender and receiving processes in hosts that are trying to start a data transmitting session between them.

It is initiated by the sending end, that set this bit to " 1", in the TCP header, starting which is known as a "3-way handshake process".

The bit SYN is not used in order to close a connection, the FIN bit is used for this purpose.

If one process set the FIN bit to "1", this means that it has no more data to send.

3 0
4 years ago
Other questions:
  • The rotor in a shaded pole motor consists of
    13·1 answer
  • How do you calculate the total voltage in a series circuit with more than one component?
    13·2 answers
  • Set numMatches to the number of elements in userValues (having NUM_VALS elements) that equal matchValue. Ex: If matchValue = 2 a
    6·1 answer
  • Indicate whether the scenario below is safe or unsafe : when storing a flammable liquid, you decide to separate it from other ma
    9·1 answer
  • Under what category of programs and apps do screen savers and backup programs fall?
    10·1 answer
  • Which of the following is Microsoft’s fastest, most efficient operating system to date: a. Offering quicker application start up
    14·1 answer
  • On the 80x86 CPU, the ESP register keeps track of the value on the top of the runtime stack.
    11·1 answer
  • Use the drop down menu to complete the sentences about changing and customizing the calendar view in outlook 2016​
    10·2 answers
  • A _ is the acknowledgment of a potential noncomformity, or an opinion regarding an issue that is not covered by a standard
    6·1 answer
  • What is the following file format called? inv_nbr, inv_name, inv_cost 876521,battery,45.00
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!