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
Which option identifies the goal in the user story in the following scenario?
Naddika [18.5K]

Answer:<u>     to purchase organic jams</u>

Explanation:

I think it is

3 0
3 years ago
Read 2 more answers
Why is the contractor normally required to submit a bid bond when making a proposal to an owner on a competitively bid contract?
just olya [345]

Answer:

It serves as a guarantee that the contractor who wins the bid will honor the terms of the bid after the contract is signed.

Explanation:

A bid bond is a type of construction bond that protects the obligee in a  construction bidding process.

A bid bond typically involves three parties:

The obligee; the owner or developer of the construction project under bid. The principal; the bidder or proposed contractor.

The surety; the agency that issues the bid bond to the principal example insurance company or bank.

A bid bond generally serves as a guarantee that the contractor who wins the bid will honor the terms of the bid after the contract is signed.

3 0
3 years ago
What is one of the “don’ts” in drawing dimension lines? they should never be labeled they should never be stacked they should ne
Strike441 [17]

Answer:

What is one of the “don’ts” in drawing dimension lines? they should never be labeled they should never be stacked they should never cross each other they should never have only one measurement value

5 0
4 years ago
Read 2 more answers
While discussing run-flat tires: Technician A says that some are self-sealing tires and are designed to quickly and permanently
musickatia [10]

Answer:

The correct option is d ( Neither A nor B)

Explanation:

Technician A made 2 mistakes in his statement.Firstly the tire is self supporting not self sealing.

Secondly, this tire does not provide permanent sealing of punctured area option a is incorrect.

This self-supporting tire after being affected with complete air leakage can temporarily bear the load of the car and avoid rolling over a distance of 80 km at a maximum speed of 55 mph. Here is what technician B suggested incorrectly as the tire after being.Here the technician B suggested incorrectly as the tire after being affected with puncture can not travel at any speed so option B is wrong

Since option a and b are incorrect and c is invalid.

4 0
3 years ago
A. Name the major strengthening mechanisms in metals and explain the working principle under each mechanism.Give the relevant eq
Sever21 [200]

Answer:

a) Solid solution strengthening and alloying,  Precipitation hardening, work hardening

b) Absence of enough  crystallographic misalignment in the grain boundary region for a small-angle

Explanation:

<u>A) strengthening mechanism</u>

i) Solid solution strengthening and alloying:

In solid solution strengthening and alloying mechanism there is an addition of one atom of solute to another during this process, there might be substitution of interstitial point defect in crystal

also the shear stress required can be represented as:  Δz = Gb√Ce^3/2

where : C = solute concentration , e = strain on material

ii) Precipitation hardening:

During precipitation hardening the alloying above the concentrate will lead to the formation of a second phase also under precipitation hardening a second phase can also be created via thermal treatments

particle bowing cab be written as :  Δz = Gb / L-2x

iii) work hardening :

Dislocation caused by stress fields been generated hardens metals under the work hardening mechanism

dislocation can be represented as ; Gb √ p

where : G = shear modulus , b = Burgess vector, p = dislocation density

B) The small angle grain boundaries are not effective enough because there is less crystallographic misalignment in the grain boundary region for a small-angle

3 0
3 years ago
Other questions:
  • You have designed a treatment system for contaminant Z. The treatment system consists of a pipe that feeds into a CSTR. The pipe
    8·1 answer
  • A quack is a data structure combining properties of both stacks and queues. It can be viewed as a list of elements written left
    5·1 answer
  • Paragraph summary on airplane history
    8·1 answer
  • A device that helps increase field worker productivity by providing reliable location and time
    13·1 answer
  • A 500 turn coil is wound on an iron core. When a 120Vrms 60Hz voltage is applied to the coil, the current is 1A rms. Neglect the
    13·2 answers
  • What historical event allowed both aerospace fields to make enormous strides<br> forward? *
    12·1 answer
  • The energy flux associated with solar radiation incident on the outer surface of the earth’s atmosphere has been accurately meas
    11·1 answer
  • Resistors of 150 Ω and 100 Ω are connected in parallel. What is their equivalent resistance?
    13·1 answer
  • What are examples of Quality Assurance workplaces? Check all that apply.
    12·2 answers
  • 2=333=3= im single text in comment
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!