answer.
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
kirill115
2 days 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:
Harlamova29_29 [926]2 days ago
5 0
See 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
Andre is finding working in an online group challenging because there are people in the group from many different cultural backg
Harlamova29_29 [926]

Answer:

Varied Communication Styles

Diverse Attitudes Toward Conflict

Different Methods for Completing Tasks

Various Decision-Making Approaches

Different Perspectives on Disclosure

Diverse Ways of Knowing

Explanation:

6 0
25 days ago
Read 2 more answers
if you had two proxy servers located in the same room, what use could you make of them? nothing create a hub sell one of the ser
Harlamova29_29 [926]
Establish a free wifi service
6 0
1 month ago
Read 2 more answers
Which of the following best describes the protocols used on the Internet?
amid [800]
Typical Internet protocols encompass TCP/IP (Transmission Control Protocol/Internet Protocol), UDP/IP (User Datagram Protocol/Internet Protocol), HTTP (HyperText Transfer Protocol), and FTP (File Transfer Protocol).
8 0
19 days ago
Which two statements are true regarding the user exec mode? (choose two.)?
Natasha_Volkova [890]
<span>To enter global configuration mode, you need to type the enable command.</span><span>
The prompt indicating this mode concludes with the ">" symbol.</span>
8 0
5 days ago
The data in a data warehouse have which of the following characteristics?
maria [879]
Option (d) is the correct choice. A data warehouse serves as a storage system that contains gathered information and data for informed decision-making via analysis. The information in a data warehouse is organized by subject and includes historical data along with sources to provide clarity. The other options are incorrect as they suggest that data is encoded differently, retrieved for limited times, updated in real-time, or structured hierarchically.
6 0
7 days ago
Other questions:
  • Why were the practitioners of alternative software development methods not satisfied with the traditional waterfall method?
    9·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • An author is preparing to send their book to a publisher as an email attachment. The file on their computer is 1000 bytes. When
    6·1 answer
  • Splunk In most production environments, _______ will be used as the source of data input?
    12·1 answer
  • (Java) Which of the following code segments correctly declare a Strings and gives it a value of "fortran".
    12·1 answer
  • 3. What is the error in the following pseudocode? // The searchName function accepts a string containing the name // to search f
    6·1 answer
  • Find true or false. A hacker is hacking software with access in sensitive information from your computer​
    9·1 answer
  • The following code is intended to test if x is NOT less than 17. Fill in the correct symbol:
    14·2 answers
  • Tanya wants to include a video with all its controls on her web page. The dimensions of the video are as follows:
    6·2 answers
  • Which of the following does not describe local alignment algorithm?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!