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
Who ate cdonalds in hell with god then died from food ppoisoning
siniylev [52]

Answer:

McDonald’s announced recently that they are going through some major menu changes, and will be nixing some unnecessary ingredients. They also are finally listening to us, and will stop using chickens that are injected with growth-promoting antibiotics, along with dairy products raised with the growth hormone rbST but they still are using a lot of factory farmed meat and the beef is still raised with antibiotics.

McDonald’s even said they might add kale to their menu, by putting it in salads or in a smoothie. I LOVE kale, and I hope they don’t find a way to ruin it. You know the saying, “You can put lipstick on a pig, but it’s still a pig”. So, they need to do a lot more than just add kale to their menu before I’d ever eat there. The problem is that millions are still eating there and consuming several questionable food additives that McDonald’s could remove entirely if they really wanted to.

Explanation:

7 0
3 years ago
How much does the transportation sector contribute to current greenhouse gas emissions? Where do most of these emissions come fr
Mekhanik [1.2K]

Answer:

29 percent

Explanation:

The transportation sector is the highest contributing factor to greenhouse gas emissions in the world. Vehicles such as cars, motorcycles, airplanes, ships etc all emit these gases which causes global warming.

Electric cars is known not to little or zero direct emission and known to be safer. It however emits nitrogen oxide which is fog like in a very minute quantity.

6 0
3 years ago
If datums are used as suggested below (A datum on shaft, B datum on face below the head, C datum on the hex flat) and order of p
allsm [11]

Answer:

a. Use datum on shaft

b. Use datum on hex flat

c. Use datum on face below the head

d. Use datum on shaft

When these datum are used, they will prevent translation and rotation along axis which they act.

6 0
3 years ago
Which sentence highlights the best way of site planning?
Nadusha1986 [10]

Answer:

Which sentence highlights the best way of site planning?

A group of construction planners are in a discussion over the most suitable plot to construct new buildings. Steven suggests that they should choose the barren stretch of land in the city and construct cluster buildings. James points out that the wetlands will provide them more area for construction. Riley advises that they should not worry about keeping large open spaces while planning building construction.

Explanation:

8 0
3 years ago
A bar of 75 mm diameter is reduced to 73mm by a cutting tool while cutting orthogonally. If the mean length of the cut chip is 7
barxatty [35]

Answer:

r=0.31

Ф=18.03°

Explanation:

Given that

Diameter of bar before cutting = 75 mm

Diameter of bar after cutting = 73 mm

Mean diameter of bar d= (75+73)/2=74 mm

Mean length of uncut chip = πd

Mean length of uncut chip = π x 74 =232.45 mm

So cutting ratio r

Cutting\ ratio=\dfrac{Mean\ length\ of cut\ chip}{Mean\ length\ of uncut\ chip}

r=\dfrac{73.5}{232.45}

  r=0.31

So the cutting ratio is 0.31.

As we know that shear angle given as

tan\phi =\dfrac{rcos\alpha }{1-rsin\alpha }

Now by putting the values

tan\phi =\dfrac{rcos\alpha }{1-rsin\alpha }

tan\phi =\dfrac{0.31cos15 }{1-0.31sin15 }\

  Ф=18.03°

So the shear angle is 18.03°.

4 0
4 years ago
Other questions:
  • Anyone know the answers to United 3 Quiz
    12·1 answer
  • What do you enjoy most and least about engineering?
    15·2 answers
  • The Greek alphabet has 24 distinct lowercase letters. How many bits are needed to be able to encode any single lowercase Greek l
    9·1 answer
  • Algebraically prove identities involving the exclusive-OR operation: (a) x ⊕ 0 = x (b) x ⊕ 1 = x′ (c) x ⊕ x = 0 (d) x ⊕ x′ = 1 (
    10·1 answer
  • What was the most recent technological shift in society
    10·1 answer
  • Which of the following sentences are written correctly verbs
    12·1 answer
  • Hi all any one help me?? ​
    12·2 answers
  • The safest hammers are those with heads that are?
    14·1 answer
  • What is the meaning of beauty and completeness? In relation to these what are the attributes a Muslim should adopt?
    15·1 answer
  • The raised areas between the grooves in a rifled bore are called:.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!