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
notsponge [240]
4 years ago
14

Using three arrays: a one-dimensional array to store the students’ names, a (parallel) two-dimensional array to store the test s

cores, and a parallel one-dimensional array to store grades. Your program must contain at least the following functions: a function called GetData to read and store data into two arrays, a function called Average that is used to calculate the average test score and grade, and a function called PrintResults to output the results. The student names should be to the left with a width of 10 columns. The test scores should be to the right with a width of 5 columns. Have your program also output the class average on a line after the output.
3 serperate arrays should be used
and it should read from a file
ive used some void functions two dimensional arrays to read numbers from a text file but im getting a lot of errors i know setw needs to be used also
Engineering
1 answer:
vodka [1.7K]4 years ago
4 0

Answer:

This C++ program considers scores as follows

A>=90

B>=80

C>=70  

D>=60

F<60

You must have a text file for input data

Here is the program as per the question

#include<iostream>

#include<fstream>

#include<string>

#include<stdlib.h>

using namespace std;

//Definition

class student

  {

  private:

  string names[80];

  int testscores[80][50];

  char grades[80];

  int count;

  public:

      void GetData();

      void Average();

      void PrintResult();

  };

void student::GetData()

  {

 

  ifstream in;

  in.open("student1.txt",ios::in);

  if(in.fail())   //test if the file exist

      {

          cout<<"Unable to open the file";

          exit(0);

      }

  count=0;

  while(!in.eof())  

      {

      in>>names[count];   //read name

      for(int i=0;i<5;i++)   // assume 5there are 5 test scores

          {

              in>>testscores[count][i];   //read scores .

          }

      count++;

      }

  count--;

  }

void student::Average()

  {

  float sum,avg;

  for(int i=0;i<count;i++)

      {

      sum=0.00;

      for(int j=0;j<5;j++)

          {

          sum=sum+testscores[i][j];

          }

      avg=sum/5;

      if(avg>=90.00)

          grades[i]='A';

      else if(avg>=80)

          grades[i]='B';

      else if(avg>=70)

          grades[i]='C';

      else if(avg>=60)

          grades[i]='D';

      else

          grades[i]='F';

      }

  }

void student::PrintResult()

  {

  for(int i=0;i<count;i++)

      {

      cout.setf(ios::left,ios::adjustfield);

      cout.width(10);

      cout<<endl<<names[i];

      cout.setf(ios::right,ios::adjustfield);

 

      for(int j=0;j<5;j++)

          {

          cout.width(5);

          cout<<testscores[i][j];

          }

      cout.width(5);

      cout<<grades[i];

      }

  }

  int main()

  {

      student obj;

      obj.GetData();

      obj.Average();

      obj.PrintResult();

      return 0;

  }

You might be interested in
What are the units or dimensions of the shear rate dv/dy (English units)? Then, what are the dimensions of the shear stress τ= μ
swat32

Answer:

1) Dimensions of shear rate is [T^{-1}] .

2)Dimensions of shear stress are [ML^{-1}T^{-2}]

Explanation:

Since the dimensions of velocity 'v' are [LT^{-1}] and the dimensions of distance 'y'  are [L] , thus the dimensions of \frac{dv}{dy} become

\frac{[LT^{-1}]}{[L]}=[T^{-1}] and hence the units become s^{-1}.

Now we know that the dimensions of coefficient of dynamic viscosity \mu are [ML^{-1}T^{-1}] thus the dimensions of shear stress can be obtained from the given formula as

[\tau ]=[ML^{-1}T^{-1}]\times [T^{-1}]\\\\[\tau ]=[ML^{-1}T^{-2}]

Now we know that dimensions of momentum are [MLT^{-1}]

The dimensions of Area\times time are [L^{2}T]

Thus the dimensions of \frac{Moumentum}{Area\times time}=\frac{MLT^{-1}}{L^{2}T}=[MLT^{-2}]

Which is same as that of shear stress. Hence proved.

4 0
3 years ago
Which one of the following is not an economic want?
Nostrana [21]

The available options are:

a. Want for a television set

b. Want for medical attention

c. Want for friendship

d. Want for new clothing

Answer:

Want for friendship

Explanation:

Given that economic want is what humans desire to have or possess such that they pay money to acquire them.

Hence, from the available options "want for friendship " is not economic want because it can't be bought with money, while other options can be bought with money or monetary transaction.

8 0
3 years ago
A composite wall is composed of 20 cm of concrete block with k = 0.5 W/m-K and 5 cm of foam insulation with k = 0.03 W/m-K. The
wariber [46]

Answer:

4.8°C

Explanation:

The rate of heat transfer through the wall is given by:

q=\frac{Ak}{L}dT

\frac{q}{A}=\frac{k}{L}dT

Assumptions:

1) the system is at equilibrium

2) the heat transfer from foam side to interface and interface to block side is equal. There is no heat retention at any point

3) the external surface of the wall (concrete block side) is large enough that all heat is dissipated and there is no increase in temperature of the air on that side

{k_{fi}= 0.03 W/m.K

{L_{fi}= 5 cm = 0.05 m

{T_{fi}= 25 \°C

{k_{cb} = 0.5 W/m.K

{L_{cb}= 20 cm = 0.20 m

{T_{cb}= 0 \°C

{T_{m}= ? \°C = temperature at the interface

Solving for {T_{m} will give the temperature at the interface:

\frac{q}{A}=\frac{k_{fi} }{L_{fi} }(T_{fi} -T_{m})=\frac{k_{cb} }{L_{cb} }(T_{m} -T_{cb})

\frac{0.03}{0.05 }(25 -T_{m})=\frac{0.5}{0.2}(T_{m} -0})

15 -0.6T_{m}=2.5T_{m}

3.1T_{m}=15

T_{m}=4.8

3 0
4 years ago
A piston–cylinder device containing carbon dioxide gas undergoes an isobaric process from 15 psia and 80°F to 170°F. Determine t
drek231 [11]

Answer:

See explanation

Explanation:

Given:

Initial pressure,

p

1

=

15

psia

Initial temperature,

T

1

=

80

∘

F

Final temperature,

T

2

=

200

∘

F

Find the gas constant and specific heat for carbon dioxide from the Properties Table of Ideal Gases.

R

=

0.04513

Btu/lbm.R

C

v

=

0.158

Btu/lbm.R

Find the work done during the isobaric process.

w

1

−

2

=

p

(

v

2

−

v

1

)

=

R

(

T

2

−

T

1

)

=

0.04513

(

200

−

80

)

w

1

−

2

=

5.4156

Btu/lbm

Find the change in internal energy during process.

Δ

u

1

−

2

=

C

v

(

T

2

−

T

1

)

=

0.158

(

200

−

80

)

=

18.96

Btu/lbm

Find the heat transfer during the process using the first law of thermodynamics.

q

1

−

2

=

w

1

−

2

+

Δ

u

1

−

2

=

5.4156

+

18.96

q

1

−

2

=

24.38

Btu/lbm

7 0
3 years ago
What is the minimum efficiency of a functioning current-model catalytic converter? a. 60% b. 75% c. 80% d. 90%
slamgirl [31]

Answer:

d. 90%

Explanation:

As we know that internal combustion engine produce lot's of toxic gases to reduce these toxic gases in the environment a device is used and this device is know as current modeling converter.

Generally the efficiency of current model catalytic converter is more than 90%.But the minimum efficiency this converter is 90%.

So option d is correct.

d. 90%

7 0
3 years ago
Other questions:
  • The moisture in hot, humid, stagnant air surrounding a cold-water pipeline continually diffuses to the cold surface where it con
    14·1 answer
  • Does a thicker core make an electromagnet stronger?
    13·1 answer
  • Air in a rigid tank is initially at 320 K and 130 kPa. Heat is added until the final pressure is 438 kPa. What is the change in
    9·1 answer
  • A car radiator is a cross-flow heat exchanger with both fluids unmixed. Water, which has a flow rate of 0.05 kg/s, enters the ra
    15·1 answer
  • Write multiple if statements
    5·1 answer
  • You must yield the right-of-way to all of the following EXCEPT:
    8·1 answer
  • 1. You are asked to write a report about one of the structures that Transportation Engineers
    9·1 answer
  • 4 points
    13·1 answer
  • Complex machines are defined by
    8·1 answer
  • A wheel spins at a constant angular speed of 24rad/s.How many revolutions will the dosk go through in 5minutes?​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!