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
What term is used to describe the discovery, collection, and analysis of evidence found on computers and networks?
Gnoma [55]
Forensics.

--------------------------------------
5 0
2 years ago
E-commerce transactions that are executed using wireless mobile devices are known as
LUCKY_DIMON [66]

Answer:

Answer is Mobile commerce

4 0
2 years ago
How teachers apply stenhouse theory
Scilla [17]

Answer:

In curriculum, a vision of knowledge, the role of the educator and a concept of the process of education are all present. In this sense, Stenhouse suggests that the role of teachers and professors is fundamental in the elaboration and implementation of curriculum.

3 0
2 years ago
Assume that you are working with spreadsheets, word processing documents, presentation slides, images, and sound files for a sch
dybincka [34]

Answer:

See explanation below.

Explanation:

File organization is very important especially when one is working with numerous files from different applications.

When you are working with spreadsheets, word processing documents, presentation slides, images and sound files, it is important to create folders and sub-folders to make locating your files a lot easier.

  1. Make sure you have all your files saved with names that are relevant to your school project.
  2. Create a sub-folder to store all spreadsheets files, create a sub-folder to store all word processing files, create a sub-folder to store all presentation slides and create another folder to store images and sound files. You do this to make it easy for you to locate whichever file you want.
  3. You create the sub-folder by right clicking on your documents section and clicking on new folder. Type in the name of the folder and save.
  4. After creating sub-folders,  create a general folder for all your folders by using the same method in step 3. Copy all your sub-folders into this major folder. You can name this folder the name of your school project.

This way, you never have to look for any files for your school project.

6 0
2 years ago
PLEASE HELP!!! WILLGIVE BRAINLIEST!!!
morpeh [17]
Black absorbs all visible parts of the spectrum turning that light energy into heat. The more it absorbs the more heat it emits.
4 0
3 years ago
Read 2 more answers
Other questions:
  • 2. What is “suspension of disbelief?” Which form of immersion is it most closely associated with?
    9·2 answers
  • What type of electronic monitoring involves an offender being contacted periodically by telephone or beeper to verify his or her
    5·1 answer
  • When a compiler finds errors, it usually indicates what they are so you can correct the code and compile the program again?
    11·1 answer
  • What error occurs in the following program? #include using namespace std; int main() { int number1, number2, sum; cout &lt;&lt;
    13·1 answer
  • The following is a true example of a computer: A. Toyota Camry
    12·1 answer
  • Write a multi-way if statement that compares the double variable pH with 7.0 and makes the following assignments to the bool var
    11·1 answer
  • . Write at least three benefits of using a network.​
    8·1 answer
  • How do you code to find the surface area 6 s2, volume s3 in python
    6·1 answer
  • A program with a graphical user inter-face for displaying HTML files, used to navigate the World Wide Web.
    8·1 answer
  • The current annual interest rate is 5 percent, and you are taking out a 20-year loan with a monthly end-of-month payment. If you
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!