Question

(Statistics) a. Write a C++ program that reads a list of double-precision scores from the keyboard into an array named scores

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

#include <iostream>

using namespace std;

int main(){

    int max = 35, count =0;

    double sum=0, average=0;

    //Declaring the array to store scores

    double marksArray[max];

    cout<<"Enter scores and any negative number to terminate"<<endl;

    //Getting the inputs from user

    //This loop will execute maximum of 35

    while(count<max){

        cin>>marksArray[count];

        //if the number is negative then loop is terminated

        if(marksArray[count]<0)

            break;

        sum = sum + marksArray[count];

        count++;

    }

    //Calculating the average

    average = sum/count;

    //Printing the scores with equivalent grade

    cout<<"Entered Scores:"<<endl;

    for(int i=0; i<count; i++){

            //if the score is below average

        if(marksArray[i]<average){

            if(marksArray[i]<=100 && marksArray[i]>=90){

                cout<<"*"<<marksArray[i]<<": A"<<endl;

            }

            else if(marksArray[i]<90 && marksArray[i]>=80){

                cout<<"*"<<marksArray[i]<<": B"<<endl;

            }

            else if(marksArray[i]<80 && marksArray[i]>=70){

                cout<<"*"<<marksArray[i]<<": C"<<endl;

            }

            else if(marksArray[i]<70 && marksArray[i]>=60){

                cout<<"*"<<marksArray[i]<<": D"<<endl;

            }

            else{

                cout<<"*"<<marksArray[i]<<": F"<<endl;

            }

        }

        //printing for scores above average

        else{

            if(marksArray[i]<=100 && marksArray[i]>=90){

                cout<<marksArray[i]<<": A"<<endl;

            }

            else if(marksArray[i]<90 && marksArray[i]>=80){

                cout<<marksArray[i]<<": B"<<endl;

            }

            else if(marksArray[i]<80 && marksArray[i]>=70){

                cout<<marksArray[i]<<": C"<<endl;

            }

            else if(marksArray[i]<70 && marksArray[i]>=60){

                cout<<marksArray[i]<<": D"<<endl;

            }

            else{

                cout<<marksArray[i]<<": F"<<endl;

            }

        }

    }

    cout<<"Total of the scores: "<<sum<<endl;

    cout<<"Average of the scores: "<<average<<endl;

    return 0;

}

Output:

C:\Users\devak\Documents\Untitled1.exe Enter scores and any negative number to terminate 100 100 90 100 100 10 99 Entered Sco

Add a comment
Know the answer?
Add Answer to:
(Statistics) a. Write a C++ program that reads a list of double-precision scores from the keyboard...
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 program named ClassifyScores that classifies a series of scores entered by the user into...

    Write a program named ClassifyScores that classifies a series of scores entered by the user into ranges (0-9, 10-19, and so forth). The scores will be numbers between 0 and 100. Design and implement a program to prompt the user to enter each score separately. If the score is within the correct range, then increment the appropriate range If the score entered is greater than 100, display an error message, ignore the incorrect score, and prompt for the user to...

  • C++ Write a program that reads the number of students in the class, then reads each...

    C++ Write a program that reads the number of students in the class, then reads each student's name and his/her test score. Print out each student name, test score and grade, and the average score of the whole class. The program must use vectors and loops for the implementation. The grades are determined as follows: A >= 90; 80 <= B < 90; 70 <= C < 80; 60 <= D < 70; F < 60.

  • In C programming Write a program that displays the appropriate prompt to input 5 scores. Once...

    In C programming Write a program that displays the appropriate prompt to input 5 scores. Once the user inputs the five integer values, your program calculates and prints the average. You do not need to declare five different variables, think of how you can get away with a single variable. The second part of this program will print A if the average of these 5 numbers is greater than or equal to 90 but less than 100, B if greater...

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

    Write a 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. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • C++ program that reads students' names followed by their test scores (5 scores) from the given...

    C++ program that reads students' names followed by their test scores (5 scores) from the given input file, students.txt. The program should output to a file, output.txt, each student's first name, last name, followed by the test scores and the relevant grade. All data should be separated by a single space. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, an array of testScores of type int...

  • 1. Write a program that reads a sequence of numbers from the keyboard, and displays the...

    1. Write a program that reads a sequence of numbers from the keyboard, and displays the smallest number. The sequence has at least one number and is terminated by -999(-999 will not appear in the sequence other than as the end marker). 2. Write a program which requests an integer input n from the keyboard and computes the sum of square of k for all k from 1 to n(inclusive). use java

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • I'm needing help writing a program that reads a list of scores from a .txt file...

    I'm needing help writing a program that reads a list of scores from a .txt file then drops the lowest. Instructions are below. Then use the "low score drop" algorithm in a program to read and process an indeterminate number of floating-point scores from a file. The program should then display the result (the lowest score in the file), with two digits after the decimal. There is no restriction on these values; they might be negative or positive, and the...

  • I need to write a program that reads an unspecified number of scores and determines how...

    I need to write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average and how many scores are below the average. Enter a negative number to signify the end of the input. Assume that the maximum number of scores is 100. PreLab07 Analyze scores Write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average and how...

  • Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment...

    Microsoft Visual Studios 2017 Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by...

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
ADVERTISEMENT