Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking.
Follow the Steps Below
//Hope this answer helps you
// If u still facee any doubt feel free to ask it in the comments
// We will be very happy to solve them
#include<bits/stdc++.h>
using namespace std;
void findAverage(string names[],int grades[][3],double averages[],int n)
{
for(int i=0;i<n;i++)
{
int sum=0;
for(int j=0;j<3;j++)
{
sum+=grades[i][j];
}
averages[i]=sum/3.0;
}
}
void displayList(const string names[],const double averages[],const int n)
{
for(int i=0;i<n;i++)
{
cout<<names[i]<<" "<<averages[i]<<endl;
}
}
void sortAverages(string names[],double averages[],int n)
{
// sorting using selection sort
int i, j, min_idx;
for (i = 0; i < n-1; i++)
{
min_idx = i;
for (j = i+1; j < n; j++)
if (averages[j] < averages[min_idx])
min_idx = j;
swap(averages[min_idx], averages[i]);
swap(names[min_idx],names[i]);// swapping names parallely with averages
}
}
int main()
{
int n;
// Input size of the class or number of total students
cout<<"Enter the number of students between 1 and 100:\n";
cin>>n;
int grades[n][3];// this 2d array will hold grades of each student
double averages[n];// This array will contain the average of the marks
string names[n];// This will contain the names of the students
cout<<"Enter the name and 3 test scores for each of the student:\n";
for(int i=0;i<n;i++)
{
cout<<"Enter the name of the student:\n";
cin>>names[i];
cout<<"Enter the marks of "<<names[i]<<":\n";
for(int j=0;j<3;j++)
{
cin>>grades[i][j];
}
}
// calling find average function
findAverage(names,grades,averages,n);
cout<<"Student's name with their averages before sorting are:\n";
displayList(names,averages,n);// This will print average and names before sorting
sortAverages(names,averages,n);
cout<<"Student's name with their averages after sorting are:\n";
displayList(names,averages,n);// This will print after sorting of averages
return 0;
}
SCREENSHOTS:
Write a C++ program that asks user number of students in a class and their names....
You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...
You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...
[JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...
Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...
In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below. Then, write methods for: Computing the...
Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...
You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...
Question: - write a C++ program that asks user to enter students' quiz scores, calculate the total score for each students and average for all. Note: - number of students: 1 through 5. That is, at least one student and up to 5. - number of quizes: 8 through 10. That is, at least 8 quizes and up to 10. - quiz score range: 0 through 100. - when entering quiz scores, if user enters -1, that means the user...
Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the user to enter a number and based on the entered number it allocates the array size. Then based on that number it asks the user that many times to enter student’s names. What you need to do: Add another array of doubles to store the gpa of each student as you enter them You need to display both the student’s name and...