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
A counter-flow double pipe heat exchanger is heat heat water from 20 degrees Celsius to 80 degrees Celsius at the rate of 1.2 kg
lakkis [162]

Answer:

L=107.6m

Explanation:

Cold water in: m_{c}=1.2kg/s, C_{c}=4.18kJ/kg\°C, T_{c,in}=20\°C, T_{c,out}=80\°C

Hot water in: m_{h}=2kg/s, C_{h}=4.18kJ/kg\°C, T_{h,in}=160\°C, T_{h,out}=?\°C

D=1.5cm=0.015m, U=649W/m^{2}K, LMTD=?\°C, A_{s}=?m^{2},L=?m

Step 1: Determine the rate of heat transfer in the heat exchanger

Q=m_{c}C_{c}(T_{c,out}-T_{c,in})

Q=1.2*4.18*(80-20)

Q=1.2*4.18*(80-20)

Q=300.96kW

Step 2: Determine outlet temperature of hot water

Q=m_{h}C_{h}(T_{h,in}-T_{h,out})

300.96=2*4.18*(160-T_{h,out})

T_{h,out}=124\°C

Step 3: Determine the Logarithmic Mean Temperature Difference (LMTD)

dT_{1}=T_{h,in}-T_{c,out}

dT_{1}=160-80

dT_{1}=80\°C

dT_{2}=T_{h,out}-T_{c,in}

dT_{2}=124-20

dT_{2}=104\°C

LMTD = \frac{dT_{2}-dT_{1}}{ln(\frac{dT_{2}}{dT_{1}})}

LMTD = \frac{104-80}{ln(\frac{104}{80})}

LMTD = \frac{24}{ln(1.3)}

LMTD = 91.48\°C

Step 4: Determine required surface area of heat exchanger

Q=UA_{s}LMTD

300.96*10^{3}=649*A_{s}*91.48

A_{s}=5.07m^{2}

Step 5: Determine length of heat exchanger

A_{s}=piDL

5.07=pi*0.015*L

L=107.57m

7 0
2 years ago
This method will sell the seat in row i and column j unless it is already sold. A ticket is sold if the price of that seat in th
blsea [12.9K]

Answer:

The solution code is written in Java.

  1. public class Movie {
  2.    private double  [][] seats = new double[5][5];
  3.    private double totalSales;
  4.    public Movie(){
  5.        for(int i= 0; i < this.seats.length; i++){
  6.            for(int j = 0; j < this.seats[i].length; j++){
  7.                this.seats[i][j] = 12;
  8.            }
  9.        }
  10.        this.totalSales = 0;
  11.    }
  12.    public boolean bookSeat(int i, int j)
  13.    {
  14.        if(this.seats[i][j] != 0){
  15.            this.totalSales += this.seats[i][j];
  16.            this.seats[i][j] = 0;
  17.            return true;
  18.        }else{
  19.            return false;
  20.        }
  21.    }
  22. }

Explanation:

The method, bookSeat(), as required by the question is presented from Line 16 - 26 as part of the public method in a class <em>Movie</em>.  This method take row,<em> i</em>, and column,<em> j</em>, as input.

By presuming the seats is an two-dimensional array with all its elements are  initialized 12 (Line 7 - 10). This means we presume the movie ticket price for all the seats are $12, for simplicity.

When the<em> bookSeat() </em>method is invoked, it will check if the current price of seats at row-i and column-i is 0. If not, the current price, will be added to the <em>totalSales </em>(Line 19)<em> </em>and then set the price to 0 (Line 20) and return <em>true</em> since the ticket is successfully sold (Line 21).  If it has already been sold, return <em>false</em> (Line 23).

8 0
3 years ago
A manometer is used to measure the air pressure in a tanlc The fluid used has a specific gravity of 1.25, and the differentialhe
Alenkasestr [34]

Answer:

(a) 11.437 psia

(b) 13.963 psia

Explanation:

The pressure exerted by a fluid can be estimated by multiplying the density of the fluid, acceleration due to gravity and the depth of the fluid. To determine the fluid density, we have:

fluid density = specific gravity * density of water = 1.25 * 62.4 lbm/ft^3 = 78 lbm/ft^3

height = 28 in * (1 ft/12 in) = 2.33 ft

acceleration due to gravity = 32.174 ft/s^2

The change in pressure = fluid density*acceleration due to gravity*height = 78*32.174*(28/12) = 5855.668 lbm*ft/(s^2 * ft^2) = 5855.668 lbf/ft^2

The we convert from lbf/ft^2 to psi:

(5855.668/32.174)*0.00694 psi = 1.263 psi

(a) pressure = atmospheric pressure - change in pressure = 12.7 - 1.263 = 11.437 psia

(b) pressure = atmospheric pressure + change in pressure = 12.7 + 1.263 = 13.963 psia

8 0
3 years ago
The formula for calculating risk considering risk perception is ?​
s2008m [1.1K]

Answer:

risk = probability x loss

Explanation:

3 0
3 years ago
Que es el crecimiento?
Grace [21]

Answer:

El crecimiento es un concepto que se refiere al aumento de tamaño, cantidad o intensidad de algo. La palabra, como tal, deriva del verbo crecer, que a su vez proviene del verbo latino crescĕre. ... Sinónimos de crecimiento son aumento, incremento, ampliación, expansión. Antónimo de crecimiento es decrecimiento

Explanation:

4 0
2 years ago
Read 2 more answers
Other questions:
  • Capitol Brewing Inc.'s management is very concerned with declining sales of their major product, a dark ale, and has asked for h
    14·1 answer
  • A groundwater contains the following cations (expressed as the cation):
    5·2 answers
  • What type of companies would employ in mechanics engineering​
    8·1 answer
  • Explain why different types of equipment are required for proper conditioning of air
    7·1 answer
  • 4. Two technicians are discussing the evaporative emission monitor. Technician A says that serious monitor faults cause a blinki
    14·1 answer
  • Why is oil black and why does oil look black
    10·1 answer
  • Resistors of 150 Ω and 100 Ω are connected in parallel. What is their equivalent resistance?
    13·1 answer
  • Some of our modern kitchen cookware is made of ceramic materials. (a) List at least three important characteristics required of
    12·1 answer
  • I ran across this symbol in some Electrical wiring documents and I am unaware of what this means. Any help?
    14·1 answer
  • Water enters a boiler at a temperature of 110°F. The boiler is to produce 2000 lb/hr of steam at a pressure of 130 psia. How man
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!