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
Ron is creating building blocks in Word. How can he make the building blocks that he created available?
ivann1987 [24]

Answer:

you can store those building blocks in the Normal template

Explanation:

Building Blocks are different pieces of content such as tables, lists, headers, and text boxes that can be added and used for your word document. In order to make these available, you can store those building blocks in the Normal template. This will allow you to instantly and repeatedly access them for various different projects that you may be working on.

8 0
3 years ago
Read 2 more answers
A goal should be___.
Luda [366]

Answer:

D

Explanation:

5 0
3 years ago
Read 2 more answers
List analog devices, Digital devices and hybrid devices
andrey2020 [161]

Answer:

Types of Hybrid Computers:

1. Large Electronic Hybrid Computer

2. General-Purpose Hybrid Computers

3. Special-Purpose Hybrid Computers

Examples of Hybrid Computers

1. Gasoline Station

2. Electrocardiogram Machine

3. Ultrasound Machine

4. Monitoring Machine

5. Research and Production Industries

6. Forensic

7. Defence

Types of Analogue Computers

1. Slide Rules

2. Differential Analysers

3. Castle Clock

4. Electronic Analogue Computers

5. Mechanical Analogue Computers

Examples of Analogue Computers

1. Thermometer

2. Speedometer

3. Analogue Clock

4. Seismometer

5. Voltmeter

6. Flight Simulators

7. Tide Predictors

Types of Digital Computers

1. Micro Computer

2. Mini Computer

3. Mainframe Computer

4. Super Computer

Examples of Digital Computers

1. Calculator

2. Digital Clock

3. Automobiles

4. Weighing Machine

5. Consumer Electronic Equipments

6. Smart Phones

7. Laptop/Personal Computer

8. ATM

3 0
2 years ago
Name 2 ways that body temperature can be taken.​
Zigmanuir [339]

Answer:

Under the armpit, which is called the axillary method, and also through mouth, which is called the oral method.

Explanation:

5 0
3 years ago
WILL GIVE BRAINLIEST IF DONE CORRECT
Juliette [100K]

Answer:

import sys

#account balance

account_balance = float(500.25)

##prints current account balance

def printbalance():

  print('Your current balance: %2g'% account_balance)

#for deposits

def deposit():

 #user inputs amount to deposit

 deposit_amount = float(input())

 #sum of current balance plus deposit

 balance = account_balance + deposit_amount

 # prints customer deposit amount and balance afterwards

 print('Deposit was $%.2f, current balance is $%2g' %(deposit_amount,

balance))

#for withdrawals

def withdraw():

 #user inputs amount to withdraw

 withdraw_amount = float(input())

 #message to display if user attempts to withdraw more than they have

 if(withdraw_amount > account_balance):

   print('$%.2f is greater than your account balance of $%.2f\n' %

(withdraw_amount, account_balance))

 else:

   #current balance minus withdrawal amount

   balance = account_balance - withdraw_amount

   # prints customer withdrawal amount and balance afterwards

   print('Withdrawal amount was $%.2f, current balance is $%.2f' %

(withdraw_amount, balance))

#system prompt asking the user what they would like to do

userchoice = input ('What would you like to do? D for Deposit, W for

Withdraw, B for Balance\n')

if (userchoice == 'D'): #deposit

 print('How much would you like to deposit today?')

 deposit()

elif userchoice == 'W': #withdraw

 print ('How much would you like to withdraw today?')

elif userchoice == 'B': #balance

 printbalance()

else:

 print('Thank you for banking with us.')

 sys.exit()

6 0
3 years ago
Read 2 more answers
Other questions:
  • To move down one paragraph, press the ____ key(s).
    15·1 answer
  • Alicia is a dietitian. She gives other people suggestions for nutrition. She wants to organize a large amount of data concerning
    8·2 answers
  • Write a switch statement that tests the value of the char variable response and performs the following actions: if response is y
    9·1 answer
  • Which is not a key factor a programmer uses in selecting the language for a project?
    9·1 answer
  • In excel, the applied theme has a set of complimentary ________, which are defined sets of formatting characteristics, such as f
    12·1 answer
  • The bearing of point p from A​
    15·1 answer
  • Write a print statement that displays a random integer between 5 and 5000. Assume the random library is imported.
    12·1 answer
  • an early type of GUI is created, which includes windows, pop-ups, icons, and menus. What year did this happen? Please help!!! qu
    12·1 answer
  • Although plants and ainamals are both living things___
    13·1 answer
  • Project: Design and Development Research Project
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!