Question

Question: - write a C++ program that asks user to enter students' quiz scores, calculate the...

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 has finished entering scores for that student.

- you may choose to calculate and display total score for each student after finishing entering all quiz scores for that student; or do so after all students scores have been entered.

- average for all: it is the average of total scores, not the average of quizes.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
  
   //setting the precision to two decimal places
   std::cout << std::setprecision(2) << std::fixed;
     
   //Declaring variables
int no_of_students,no_of_quizes;
int quiz_score;

/* This while loop continues to execute
* until the user enters a valid number
*/
while(true)
{
cout<<"Enter no of students :";
cin>>no_of_students;
if(no_of_students<1 || no_of_students>5)
{
    cout<<"** Invalid.Must be between 1 and 5 **"<<endl;
    continue;
   }
   else
   break;   
}

/* This while loop continues to execute
* until the user enters a valid number
*/
while(true)
{
    cout<<"Enter no of quizes :";
    cin>>no_of_quizes;
    if(no_of_quizes<8 || no_of_quizes>10)
    {
        cout<<"** Invalid.Must be between 8 and 10 **"<<endl;
        continue;
   }
   else
   break;
}
int arr[no_of_students][no_of_quizes];

for(int i=0;i<no_of_students;i++)
{
    for(int j=0;j<no_of_quizes;j++)
    {
        arr[i][j]=0;
   }
}
int val;
for(int i=0;i<no_of_students;i++)
{
    cout<<"Enter Student#"<<i+1<<" quiz scores :"<<endl;
    for(int j=0;j<no_of_quizes;j++)
    {
        cout<<"Enter Score :"<<j+1<<":";
        cin>>val;
        if(val==-1)
        {
       
        break;  
       }
       else
       {
           arr[i][j]=val;  
       }
       
   }
}   

double tot=0,avg=0;
int cnt=0;
for(int i=0;i<no_of_students;i++)
{
tot=0;
   cnt=0;  
    for(int j=0;j<no_of_quizes;j++)
    {
    if(arr[i][j]!=0)
    {
        cnt++;
        tot+=arr[i][j];
   }
   }
   avg=tot/cnt;
   cout<<"Average Total Score of Student#"<<i+1<<":"<<avg<<endl;
}   
  

   return 0;
}


____________________________

Output:

_______________Thank You

Add a comment
Know the answer?
Add Answer to:
Question: - write a C++ program that asks user to enter students' quiz scores, calculate the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • - write a C++ program that asks user to enter students' quiz scores, calculate the total...

    - 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 has...

  • Using the nested loop in C++ to finish the program //test scores. //It asks the user...

    Using the nested loop in C++ to finish the program //test scores. //It asks the user for the // number of students and //the number of test scores //per student. // Calc. and display average score // for each TEST 2 4 6 7

  • Write a program that will ask the user to enter 4 quiz scores. These scores should...

    Write a program that will ask the user to enter 4 quiz scores. These scores should be from 0 to 100. Use a procedure and pass by reference to get these scores. Write a function that will find the lowest score. This score will be sent back through the function call. You still need to pass the scores by value to this function. Write a function that will calculate the average score. This value will be sent back to main...

  • Write a Python program that asks the user to type in their three quiz scores (scores...

    Write a Python program that asks the user to type in their three quiz scores (scores between 0 and 100) and displays two averages. The program should be written so one function gets the user to input a score, another function takes the three scores and returns the average of them. And another function takes the three scores and averages the two highest scores (in other words, drops the lowest). Each of these functions should do the computation and return...

  • Write a C++ program that asks user number of students in a class and their names....

    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 Save the project as A4_StudentRanking_yourname....

  • Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and...

    Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and calculate the average score over a number of tests for a number of students. The program should: 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the scores...

  • Small Basic Programming Question: Average score Write a program that uses loops to collect data and...

    Small Basic Programming Question: Average score Write a program that uses loops to collect data and calculate the average score over a number of tests for a number of students. The program should : 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the...

  • Write a javascript program that asks the user to enter five test scores. The program should...

    Write a javascript program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage—This method should accept five test scores as arguments and return the average of the scores. determineGrade—This method should accept a test score as an argument and return a letter grade for the score,

  • Write a program that allows the user to enter a series of exam scores. The number...

    Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...

  • C++ programming language Write a program that asks the user for a file name. The file...

    C++ programming language Write a program that asks the user for a file name. The file contains a series of scores(integers), each written on a separate line. The program should read the contents of the file into an array and then display the following content: 1) The scores in rows of 10 scores and in sorted in descending order. 2) The lowest score in the array 3) The highest score in the array 4) The total number of scores in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT