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
How do you solve this. I dont know how so I need steps if you dont mind
galben [10]

Explanation:

all I know is every number that have a bar on is equal to one

4 0
3 years ago
Ductility (increases/decreases/does not change) with temperature.
PSYCHO15rus [73]

Answer:

Increases

Explanation:

Ductility:

    Ductility is the property of material to go permanent deformation due to tensile load.In other words the ability of material to deform in wire by the help of tensile load.

When temperature is increase then ductility will also increases.And when temperature decreases then the ductility will also decreases.As we know that at very low temperature material become brittle and this is know as ductile brittle transition.

8 0
3 years ago
Under EPA's regulations, which of the following methods can be used to pressurize an R11 or R123 system for the purpose of openi
Natasha2012 [34]

Answer:

(A) Adding Nitrogen

Explanation:

R11 or R123 are flammable substance under certain conditions when mixed with Oxygen, adding Nitrogen is a safety procedure used in displacing any R11 or R123 which are considered as hazardous when mixed with Oxygen.

7 0
3 years ago
A cyclone is operated in a closed circuit with a ball mill. The cyclone is feed from a rod mill with a slurry that has a density
pav-90 [236]
Here is the flow sheet. Hope this helps have a great day!!

3 0
3 years ago
The assembly consists of two 10 mm diameter red brass C83400 coper rods AB and CD, a 15 mm diameter 304 stainless steel of EF an
My name is Ann [436]

Answer:

Therefore, the horizontal displacement of end F of rod EF is 0.4797 mm

Explanation:

solution is mentioned in steps.

6 0
3 years ago
Other questions:
  • ): drivers must slow down from 60 to 40 mi/hr to negotiate a severe curve. A warning sign is visible for a distance of 120 ft. H
    7·1 answer
  • Implement Heap (constructors, trickleUp and trickleDown), MyPriorityQueue (constructor, offer, poll, peek and isEmpty) and HeapS
    12·1 answer
  • Air enters a compressor operating at steady state with pressure of 90 kPa, at a temperature of 350 K, and a volumetric flow rate
    13·1 answer
  • The exterior brick surface of a house has a surface area of 203203 m2 in the winter when the temperature is 0.000.00 °C. How muc
    9·1 answer
  • Train levels a station and travels north at 60km/hr. Two hours later, a second train leaves on a parallel track and travels nort
    12·1 answer
  • Under maximum power transfer conditions, the operating efficiency of a system is 100%. (a) True (b) False
    6·1 answer
  • Thanks for the help!
    11·1 answer
  • THE COMPUND INTEREST ON RS 30,000AT 7% PER ANNUM IS RS 4347 THE PERIOD IN YEARS
    7·2 answers
  • A 1,040 N force is recorded on a hemispherical vane as it redirects a 2.5 cm- blade diameter water jet through a 180 angle. Dete
    11·1 answer
  • What are some benfits of getting involved with 4h
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!