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
11111nata11111 [884]
4 years ago
7

Your program must output each student’s name in the form: last name followed by a comma, followed by a space, followed by the fi

rst name; the name must be left justified. Moreover, other than declaring the variables and opening the input and output files, the function main should only be a collection of function calls.
Engineering
1 answer:
Reptile [31]4 years ago
3 0

Answer:

#include <iostream>

#include <string>

#include <fstream>

using namespace std;

char getStudentGrade(int testScore);

//Declare constant max students in file 10

const int maxStudents = 10;

struct StudentType

{

  string studentFName;

  string studentLName;

  int testScore;

  char grade;

};

void readStudentData(StudentType students[]){

  int i = 0;

 

  ifstream infile;

  infile.open("inputStudentData.txt");

 

 

  while (!infile.eof())

  {

   infile >> students[i].studentFName;

   infile >> students[i].studentLName;

   infile >> students[i].testScore;

   students[i].grade = getStudentGrade(students[i].testScore);

      i++;

  }

}

char getStudentGrade(int testScore){

  char grade;

  if(testScore >= 80) {

      grade = 'A';      

  }

  else if(testScore >= 60) {

      grade = 'B';

  }

  else if(testScore >= 50) {

      grade = 'C';  

  }

  else if(testScore >= 40) {

      grade = 'D';      

  }

  else {

      grade = 'F';  

  }

  return grade;

}

int main()

{

 

  StudentType students[10];

 

  readStudentData(students);

 

  for(int i=0;i<maxStudents;i++) {

      students[i].grade = getStudentGrade(students[i].testScore);

  }

 

  for(int i=0; i<maxStudents; i++){    

      cout << students[i].studentLName <<", " << students[i].studentFName << " " << students[i].grade << endl;

  }

  ofstream outputFile;

  outputFile.open ("outputStudentData.txt");

 

  for(int i=0; i<maxStudents; i++){    

      outputFile << students[i].studentLName <<", " << students[i].studentFName << " " << students[i].grade << endl;

  }

  outputFile.close();

  return 0;

}

You might be interested in
In primary processing their are 3 different steps, what are the steps?
Nana76 [90]

Answer:

Primary processing involves cutting, cleaning, packaging, storage and refrigeration of raw foods to ensure that they are not spoilt before they reach the consumer.

8 0
3 years ago
A Carnot refrigeration cycle absorbs heat at -12 °C and rejects it at 40 °C. a)-Calculate the coefficient of performance of this
tresset_1 [31]

Answer:

a)COP=5.01

b)W_{in}=2.998 KW

c)COP=6.01

d)Q_R=17.99 KW

Explanation:

Given

T_L= -12°C,T_H=40°C

For refrigeration

  We know that Carnot cycle is an ideal cycle that have all reversible process.

So COP of refrigeration is given as follows

COP=\dfrac{T_L}{T_H-T_L}  ,T in Kelvin.

COP=\dfrac{261}{313-261}

a)COP=5.01

Given that refrigeration effect= 15 KW

We know that  COP=\dfrac{RE}{W_{in}}

RE is the refrigeration effect

So

5.01=\dfrac{15}{W_{in}}

b)W_{in}=2.998 KW

For heat pump

So COP of heat pump is given as follows

COP=\dfrac{T_h}{T_H-T_L}  ,T in Kelvin.

COP=\dfrac{313}{313-261}

c)COP=6.01

In heat pump

Heat rejection at high temperature=heat absorb at  low temperature+work in put

Q_R=Q_A+W_{in}

Given that Q_A=15KW

We know that  COP=\dfrac{Q_R}{W_{in}}

COP=\dfrac{Q_R}{Q_R-Q_A}

6.01=\dfrac{Q_R}{Q_R-15}

d)Q_R=17.99 KW

5 0
4 years ago
Salvage ethnography is the effort to ensure that ethnography remains an important part of anthropology. recording of linguistic
fenix001 [56]

Answer:

                D

Explanation:

                            D

6 0
4 years ago
the employer must comply with an employees or employee representative request to examine and copy abatement documents within
frez [133]
The employer must inform employees and their representatives of their right to examine and copy all abatement documents submitted to the Agency. ... The employer must comply with an employee's or employee representative's request to examine and copy abatement documents within 5 working days of receiving the request.
3 0
3 years ago
Explain all the characteristics of computer<br>​
Sedaia [141]
They are as follows-

Speed
Accuracy
Storage
Versatility
Diligence
Automation
Reliability
Power of Remembering

Let us understand each characteristic in brief:-

Speed – Speed of a computer means the time it takes to complete any given task. The computer works at a very lightning speed. For example, a computer takes a second to calculate 3 million calculations rather than a human which takes years. Hence nowadays the speed of the computer is measured in terms of microseconds, Nanoseconds, and even in Pico seconds instead of seconds or milliseconds.


Accuracy – The computers are programmed and designed in such a manner that their results are almost 100% accurate. It performs all the tasks with the same accuracy. There are very few chances of uncertainty in results and even though an error occurs, it can happen either due to wrong input data or unreliable programs by a programmer. Such errors are referred to as Garbage In Garbage Out (GIGO) which means, if you provide wrong instructions to the computer then you get wrong results.


Versatility – Along with being accurate and diligent a computer is also a versatile device. It can perform several types of tasks at a time if they are reduced to a certain set of logical steps. A computer can be used for many purposes at different places such as booking air and rail tickets, weather forecasting, listening to music, and playing games. Also at a time, one can pay his utility bills and can make a monthly budget too. It can prepare documents, data sheets and also can make models of houses, dams, etc.
Diligence – The ability of a computer to perform tasks without getting tired is known as diligence. Computers are highly reliable, they do not get fed up, exhausted, or lack concentration. They can work for hours and hours unlike humans and can give accurate or error-free results. For example, humans will start feeling tired after 2 -3 hours and will lack concentration whereas a computer will keep on working until the results are achieved.
Automation – Automation means working automatically. A computer can work on its own without the intervention of the person using it. Programs can be made for the computer to perform the task and based on the sequence it executes the tasks and gives accurate results. In case an error occurs, it gives error messages too and registers the logs.
Reliability – High reliability of a computer depends on low failure rate and easy maintenance. The results given out by the computer are reliable as the accuracy is almost 100%.
Power of Remembering – The computer has the power of storing data or information for several years. It cannot lose the data on its own. A person can retrieve the data whenever required and the data remains the same after a number of years also. It gives the freedom to the user to decide on how much data to store and how much to remove.
5 0
3 years ago
Other questions:
  • Air is flowing in an insulated duct at a rate of 2 kg/sec. Air enters the duct at 40 oC and 8-kW of heat is added with a electri
    5·1 answer
  • Felix has placed some Copper wire (where the official looked up inferred absolute temperature is 234.5 Celsius) 28 gauge wire in
    14·1 answer
  • A thermocouple junction is used to measure the temperature of a solid material. The junction is inserted into a small circular h
    6·1 answer
  • Define construction document​
    5·1 answer
  • م
    12·1 answer
  • Question # 8
    15·1 answer
  • On some engines after torquing cylinder head fasteners you must
    12·1 answer
  • Situation: Peter is designing a new hybrid car that functions on solar power. He is currently working on sketches of his design
    7·1 answer
  • How to tie shoe please
    6·1 answer
  • Contrast moral and immoral creativity and innovation<br>​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!