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]
2 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]2 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
Your task is to identify three or more ways that big data is being collected on a regular basis, including one data collection m
attashe74 [19]

Answer:

Data is one of the most valuable resources today's businesses have. ... There are various data-gathering methods you can use with the help of your ... When it comes to data businesses collect about their customers, ... Third-party data offers much more scale than any other type of data, ... Big White Cursor.

Explanation:

4 0
3 years ago
Extend the class linkedListType by adding the following operations: Write a function that returns the info of the kth element of
WINSTONCH [101]

Answer:

Explanation:

The following code is written in Java. Both functions traverse the linkedlist, until it reaches the desired index and either returns that value or deletes it. If no value is found the function terminates.

public int GetNth(int index)

       {

       Node current = head;

       int count = 0;

       while (current != null)

       {

       if (count == index)

       return current.data;

       count++;

       current = current.next;

       }

       assert (false);

       return 0;

       }

public int removeNth(int index)

       {

       Node current = head;

       int count = 0;

       while (current != null)

       {

       if (count == index)

       return current.remove;

       count++;

       current = current.next;

       }

       assert (false);

       return 0;

       }

6 0
3 years ago
Describe how computer are used in ticket counter?​
m_a_m_a [10]

Answer:

These systems are commonly used in facilities such as public libraries to ensure equitable use of limited numbers of computers. Bookings may be done over the internet or within the library itself using a separate computer set up as a booking terminal.

6 0
2 years ago
What unit is used to describe the smallest amount of bitcoin?
diamong [38]

Answer:

The satoshi is currently the smallest unit of the bitcoin currency recorded on the block chain. It is a one hundred millionth of a single bitcoin (0.00000001 BTC).

Explanation:

A bitcoin is a type of digital currency in which a record of transactions is kept and new units of currency are generated by the computational solution of mathematical problems. Bitcoins operate independently through a central bank.

7 0
2 years ago
Students with "Red" hair had the highest average number of free throws made on the "Hair Color Summary" table and students with
erik [133]
Babe he is is dis d did d did. D
4 0
3 years ago
Other questions:
  • What is a Photojournalist
    5·1 answer
  • Identify a factor that is unlikely to influence the length of time people wait in the lunch line.
    8·2 answers
  • Jim is in the market for a car that will last for the next 10 years and has saved up some money for the purpose of a car. What’s
    8·2 answers
  • Explain the importance of determinism in an industrial LAN
    8·1 answer
  • The physical parts of the computer are known as?
    14·1 answer
  • If two egg cells are fertilized what will happen?
    10·1 answer
  • Which type(s) of license(s) allow the underlying software code to be viewed?
    15·1 answer
  • Write a method that takes a RegularPolygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclus
    10·1 answer
  • Which tags do you use to write the header and items of an ordered list on a web page?
    14·1 answer
  • Consider that a man is watching a picture of a Black Horse. He receives an external stimulus from input channel. Man gains some
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!