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
iren [92.7K]
2 years ago
13

Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed

by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and 100), and grade of type char. Suppose that the class has 20 students. Use an array of 20 components of type studentType. Your program must contain at least the following functions: A function to read the students’ data into the array. A function to assign the relevant grade to each student. A function to find the highest test score. A function to print the names of the students having the highest test score. Your program must output each student’s name in this form: last name followed by a comma, followed by a space, followed by the first 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.
Computers and Technology
1 answer:
bekas [8.4K]2 years ago
5 0

Answer:

See explaination

Explanation:

#include <iostream>

#include <iomanip>

#include <fstream>

#include <string>

using namespace std;

void readStudentsData();

void levels(int&,int&,int&);

int main()

{

string studentsName[50];

int grade[50];

int highestScore = 0;

int belowAverage = 50;

int countStudents = 0;

int sum = 0;

int score[5]=

double average = 0;

ifstream infile;

ofstream outfile;

void readStudentsData();

infile.open("c:\\Data.txt");

int numOfStudents = 0;

infile >> studentsName[numOfStudents] >> grade[numOfStudents];

While (infile && numOfstudents < 50)

{

numOfStudents++;

infile >> studentsName[numOfStudents] >> grade[numOfStudents};

}

if (!infile)

{

cout << "File does not open." << endl;

return 1;

}

outfile.open("c:\\average.out");

outfile << fixed << showpoint;

outfile << setprecision(2);

infile >> studentsName;

infile >> score1 >> score2 >> score3 >> score4 >> score5 >>;

outfile << left << setw(20) << "Students Name"

<< setw(5) << "Score 1" << setw(5) << "Score 2"

<< setw(5) << "Score 3" << setw(5) << "Score 4"

<< setw(5) << "Score 5" << setw(5) << "Grade"

<< setw(5) << "Average" << setw(5) << "Below average"

<< setw(5) << "Highest" << endl;

if (average >= 90)

cout << "A" << endl;

else if (average >= 80)

cout << "B" << endl;

else if (average >= 70)

cout << "C" << endl;

else if (average >= 60)

cout << "D" << endl;

else

cout << "F" << endl;

}

average = static_cast<double>(score1+score2+score3+score4+score5) /5;

void level(int &highestScore,int &belowAverage,int &sum);

{

int level,high = 0,low = 17;

infile >> level;

while(level!=-1)

{

sum = sum + level;

if (level > high)

{

high = level;

infile >> level;

}

else

if (level < low)

{

low = level;

infile >> level;

}

else

if infile >> level;

}

outfile << ' ' << high;

else

if (high > highestScore)

highestScore=high;

else

if (low < belowAverage)

belowAverage=low;

}

do

{

cout << "Students Name: ";

cin >> name

cout << "Input score: " << endl;

cin >> score1>> score2>> score3>> score4>> score5;

cout << Students Name << Highest score);

}

While (highest score !=0);

infile.close();

outfile.close();

return 0;

}

You might be interested in
Write a static method named anglePairs that accepts three angles (integers), measured in degrees, as parameters and returns whet
padilas [110]

Answer:

The java program for the scenario is given below.  

import java.util.*;

public class Test

{

// method returning sum of all digits in the integer parameter

static boolean anglePairs(int a1, int a2, int a3)

{

   // variable to hold sum of two complementary angles

   int comp=90;  

   // variable to hold sum of two supplementary angles

   int supp=180;

   // boolean variable to hold result

   boolean result = false;

   if( (a1+a2 == comp) || (a2+a3 == comp) || (a1+a3 == comp) )

   {

       if( (a1+a2 == supp) || (a2+a3 == supp) || (a1+a3 == supp) )

           result = true;

       else

           result = false;

   }    

           // return variable result

       return result;

}

public static void main(String[] args)

{

   // method is called by passing three positive angles

   System.out.println("The pair of angles have both complementary and supplementary angles " + anglePairs(100, 80, 90) );    

}

}

OUTPUT

The pair of angles have both complementary and supplementary angles false

Explanation:

The program works as described below.

1. The method, anglePairs(), is declared as static having return type as Boolean which takes three positive integer parameters.

static boolean anglePairs(int a1, int a2, int a3)

{

}

2. The integer variable, comp, is declared and initialized to 90.

3. The integer variable, supp, is declared and initialized to 180.

4. The Boolean variable, result, is declared and initialized to false.

5. Using if-else statements, sum of two angles are compared with the variables, comp and supp.

6. If the sum of any two angles match with both, comp and supp, variables, the Boolean variable, result is assigned value true. Otherwise, result is assigned value false.

7. The value of result is returned.

8. Inside main() method, the function anglePairs() is called and three positive numerical values are passed as parameters.  The output is displayed.

9. All the above code is written inside the class Test.

10. User input is not taken since it is not mentioned in the question.

8 0
3 years ago
The location on the Word screen where text will be entered is known as the _____.
mixas84 [53]
Insertion point is represented by blinking vertical line
4 0
2 years ago
7. Write a Qbasic program to read the value
Shtirlitz [24]

Answer:

PRINT "Values for Principal (P), Rate (A) and Time (T)"

INPUT P, A, T

I = P * A * T/100

Amount = P + I

PRINT "Interest: ", I

PRINT "Amount: ", Amount

Explanation:

This prompts the user for values for Principal, Rate and Time

PRINT "Values for Principal (P), Rate (A) and Time (T)"

This gets values for Principal (P), Rate (R) and Time (T)

INPUT P, A, T

This calculates the interest (I)

I = P * A * T/100

This calculates the amount (A)

Amount = P + I

This prints the interest (I)

PRINT "Interest: ", I

This prints the amount (A)

PRINT "Amount: ", Amount

4 0
2 years ago
2. Name the three building blocks of design that pertain to form.
inna [77]

Answer:

Point, Line, Shape,Form, Color, Value, and Texture.

Explanation:

The elements of design, are the building blocks used by the designers to create the designs. ...

Point, Line, Shape,Form, Color, Value, and Texture.

3 0
3 years ago
Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
kondaur [170]

in c++

...

for(auto& el:hourlyTemp){

std::cout<<el<<", ";

}

...

This is called Range-based loop or for each loop

5 0
3 years ago
Other questions:
  • True or false? if the copyright date on the homepage is more than 1 year old, the website should always be considered unmaintain
    5·1 answer
  • Draw a logic circuit for the function F = (A + B)(B + C)(A + C), using NOR gates only. ​
    9·1 answer
  • In order to install a device, the operating system needs the required __________ for that device.
    13·2 answers
  • What important feature of an email gives you a clue about what the sender wants to tell you?
    12·2 answers
  • . A collection of programs designed to create and manage databases is called a(n))
    13·1 answer
  • Define the function max2 that takes two integers as arguments and returns the largest of them. Then define the function max_list t
    11·1 answer
  • This is your code.
    9·1 answer
  • Create an online order form for a car rental store and include the following items: input text box to enter the number of days i
    14·1 answer
  • Cleo is new to object oriented programming. which type of action can be taken on on object?
    14·2 answers
  • (b) Cell B12 contains the formula, ROUND((SUM(B5:B9)*D1),1).
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!