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]
3 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]3 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
BE-40 What is a characteristic of a catamaran hull?
Nat2105 [25]

Answer:

<em>A stable ride</em>

Explanation:

A Catamaran hull is a form of sea craft invented by the Austronesian peoples, the invention of the Catamaran hull enabled these people to sail across the sea in their expansion to the islands of the Indian and Pacific Oceans. Catamaran has multiple hulls, usually two parallel hulls of equal size. This geometric feature gives the craft an increased stability because,<em> it derives extra stability from its wide beam, in the place of a ballasted keel employed in a regular monohull sailboat. </em>A Catamaran hull will require four times the force needed to capsize it, when compared to an equivalent monohull.

8 0
3 years ago
What do we need to travel farther distances in space
kakasveta [241]

Answer

Definitely a

Explanation:

Because OK yes the space suit is necessary and everything but u can't get to space without the shuttle

6 0
2 years ago
Read 2 more answers
Luợng hơi nước có lưu lượng 100kg/s ở áp suất đầu p;= 20bar, nhiệt độ đầu t; =400°C giãn nở đoạn nhiệt trong tuabin đến độ khô X
Valentin [98]

Answer:

Explanation:

.

3 0
3 years ago
The column is constructed from high-strength concrete and eight A992 steel reinforcing bars. If the column is subjected to an ax
Mumz [18]

Answer:

d= 2.80inch

Explanation:

Given:

Axial force= 30kip

d= 1inch

CHECK THE ATTACHMENT FOR DETAILED EXPLANATION

3 0
3 years ago
The USAF is thinking of purchasing a improved automatic controller (no human required) at a cost of $100,000 that can make 4,000
blsea [12.9K]

Answer:

It would take 3225.8 hours of target detection to pay off the new controller

Explanation:

First, to find out how many hours it would take, we calculate what is the cost per contact for both options:

\mbox{cost per contact}=\frac{\mbox{cost per hour}}{\mbox{contacts per hour}} \\\\\mbox{cost per contact}_{specialist} =\frac{8 \frac{\$}{h} }{1000\frac{contacts}{hour} } =8*10^{-3} \frac{\$}{contact}\\\\\mbox{cost per contact}_{controller} =\frac{1 \frac{\$}{h} }{4000\frac{contacts}{hour} } =2.5*10^{-4} \frac{\$}{contact}

Knowing the cost per contact, we calculate savings per contact when using the controller:

Savings=\mbox{cost per contact}_{specialist}-\mbox{cost per contact}_{controller}\\Savings=8*10^{-3} \frac{\$}{contact}-2.5*10^{-4} \frac{\$}{contact}=7.75*10^{-3} \frac{\$}{contact}

Now that we know how much the automatic controller saves, we calculate how many contacts it would take to pay it off, and then, taking into account contacts per hour, how many hours:

Hours=\frac{\mbox{cost of the controller}}{\mbox{savings per contact}}*\frac{\mbox{1}}{\mbox{contacts per hour}}  \\\\Hours=\frac{\$100000}{7.75*10^{-3} \frac{\$}{contact}} *\frac{\mbox{1}}{4000\frac{contacts}{hour} }}=3225,8 \mbox{ hours}

That means, without taking into account veteran benefits (that raise the cost of the USAF specialist), it would take around 134 days of target detection to pay off the new controller.

8 0
3 years ago
Other questions:
  • Find the time-domain sinusoid for the following phasors:_________
    6·1 answer
  • Why or why not the following materials will make good candidates for the construction of
    15·1 answer
  • How do I calculate the gear ratio​
    6·1 answer
  • Suppose that the voltage is reduced by 10 percent (to 90 VV). By what percentage is the power reduced? Assume that the resistanc
    10·1 answer
  • Someone please help me with this I’m stuck on it ?!i don’t have a lot of time
    12·1 answer
  • A chemistry student accidentally drops a large mercury thermometer and it breaks. The thermometer contained 2 grams of mercury (
    13·1 answer
  • In software engineering how do you apply design for change?
    13·1 answer
  • Make a sketch of a simple mechanically expanded brake and indicate the forces ​ ​ acting on the leading shoe when the brake is a
    10·1 answer
  • Which company introduced the Windows operating system correct answer plz <br>​
    13·1 answer
  • An electrical layout is a drawing that indicates how the ________ of a circuit will be connected to one another and where the wi
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!