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 enter the next score.
If the score entered is less than 0, the program should display the result and terminate.
For example, if the user enters 1 score between 20 and 29, 2 scores between 40 and 49, 3 scores between 50 and 59, etc. The program should display the following.
Range Number of scores
0-9 0
10-19 0
20-29 1
30-39 0
40-49 2
50-59 3
60-69 1
70-79 7
80-89 5
90-100 3
Hint: Create an array with 10 elements, one for each range. When each score is entered, increment the appropriate array element. The array index for each range can be calculated by (score / 10). Please note that when the score is 100, the appropriate array index cannot be calculated this way.
Note: The user of your program can enter as many scores as (s)he wishes. The user identifies the end by entering a negative number for score; your program then should display the tabulated scores and exit.
Java code:
create a file name Score.java and paste given code into it!
import java.util.Scanner;
import java.lang.*;
public class Score {
public static void main(String[] args)
{
int v[]=new int[10];
for (int i = 0; i < 10; ++i)
{
v[i] = 0;
}
while(true)
{
System.out.println("Enter the Score between 0 and 100!");
int s ;
Scanner scanner = new
Scanner(System.in);
s =
scanner.nextInt();
if(0<= s && s
<= 100)
{
if(0 <= s && s <= 9 )
{
v[0] = v[0] + 1;
}
else if(10 <= s && s <= 19 )
{
v[1] = v[1] + 1;
}
else if(20 <= s && s <= 29 )
{
v[2] = v[2] + 1;
}
else if(30 <= s && s <= 39 )
{
v[3] = v[3] + 1;
}
else if(40 <= s && s <= 49 )
{
v[4] = v[4] + 1;
}
else if(50 <= s && s <= 59 )
{
v[5] = v[5] + 1;
}
else if(60 <= s && s <= 69 )
{
v[6] = v[6] + 1;
}
else if(70 <= s && s <= 79 )
{
v[7] = v[7] + 1;
}
else if(80 <= s && s <= 89 )
{
v[8] = v[8] + 1;
}
else if(90 <= s && s <= 100 )
{
v[9] = v[9] + 1;
}
}
else if(s >
100)
{
System.out.println("Please enter the Score between 0 and
100!");
}
else
{
int start = 0;
for (int i = 0; i < 10; ++i)
{
System.out.println(start + "-" + (start + 9) + "\t\t" +
v[i]);
start = start + 10;
}
break;
}
}
}
}
C++ code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v(10);
for (int i = 0; i < 10; ++i)
{
v[i] = 0;
}
while(true)
{
cout << "Enter the Score between 0 and 100!\n";
int s ;
cin >> s;
if(0<= s and s <= 100)
{
if(0 <= s and s <= 9 )
{
v[0] = v[0] + 1;
}
else if(10 <= s and s <= 19 )
{
v[1] = v[1] + 1;
}
else if(20 <= s and s <= 29 )
{
v[2] = v[2] + 1;
}
else if(30 <= s and s <= 39 )
{
v[3] = v[3] + 1;
}
else if(40 <= s and s <= 49 )
{
v[4] = v[4] + 1;
}
else if(50 <= s and s <= 59 )
{
v[5] = v[5] + 1;
}
else if(60 <= s and s <= 69 )
{
v[6] = v[6] + 1;
}
else if(70 <= s and s <= 79 )
{
v[7] = v[7] + 1;
}
else if(80 <= s and s <= 89 )
{
v[8] = v[8] + 1;
}
else if(90 <= s and s <= 100 )
{
v[9] = v[9] + 1;
}
}
else if(s > 100)
{
cout << "Please enter the Score between 0 and 100!\n";
}
else
{
int start = 0;
for (int i = 0; i < 10; ++i)
{
cout << start << "-" << (start + 9) <<
"\t\t" << v[i] << endl;
start = start + 10;
}
break;
}
}
return 0;
}
Sample Output:
Enter the Score between 0 and 100!
5
Enter the Score between 0 and 100!
6
Enter the Score between 0 and 100!
7
Enter the Score between 0 and 100!
88
Enter the Score between 0 and 100!
89
Enter the Score between 0 and 100!
87
Enter the Score between 0 and 100!
55
Enter the Score between 0 and 100!
56
Enter the Score between 0 and 100!
57
Enter the Score between 0 and 100!
101
Please enter the Score between 0 and 100!
Enter the Score between 0 and 100!
-1
0-9 3
10-19 0
20-29 0
30-39 0
40-49 0
50-59 3
60-69 0
70-79 0
80-89 3
90-99 0
Write a program named ClassifyScores that classifies a series of scores entered by the user into...
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...
Write a short C++ program that prompts the user for a series of ten scores in the range of 0-10 and adds them into a total. Check to make sure the numbers that are entered are actually in the proper 0-10 range. If a 10 is entered then add the ten to the total then double the total to that point. If a 5 is entered then add five to the total then divide the total by 2 (throwing away any remainders)...
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 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...
Name your c++ file cpp. BScore_LastNameFirstName.cpp Write a program that contains a function call Input. The Input function should accept 2 decimal test scores that was entered from the user and stores them in an array. Don’t store any number less than 0. Return the array to main. Inside main, the program should pass the array and the total number of scores to countBGrade function. The countBGrade function should count how many B scores (80 to 89) were entered by...
Write a program that instantiates an array of integers named scores. Let the size of the array be 10. The program then first invokes randomFill to fill the scores array with random numbers in the range of 0 -100. Once the array is filled with data, methods below are called such that the output resembles the expected output given. The program keeps prompting the user to see if they want to evaluate a new set of random data. Find below...
In C++
2. Write a program that allows the user to enter a series of positive numbers between 1 and 100 and displays the smallest and largest of the numbers entered. The program should not store the numbers that were entered, only keep track of the smallest and largest ones. The program should continue accepting numbers until the value 0 is entered and then display the results. If a number out of range is entered, tell the user it is...
(Statistics) a. Write a C++ program that reads a list of double-precision scores from the keyboard into an array named scores. It is assumed that the user will enter no more than 35 scores. The scores are to be counted as they're read, and entry is to be terminated when a negative value has been entered. After all scores have been input, your program should find and display the sum and average of the scores. The scores should then be...
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 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,