Question

Create a program to calculate and print basic stats on a set of a given input...

Create a program to calculate and print basic stats on a set of a given input values representing students' scores on an quiz.

1) Ask the user for the total number of quiz scores to be input (assume a positive integer will be given).

2) Create an array to hold all the quiz scores and then get all the scores from input to put into the array. For example, if the user input 10 in step (1) then you should create an array to hold 10 double values (each of the 10 quiz scores) and ask the user for the 10 values, one-by-one, to put in each spot. You may assume that each quiz score will be a double between 0.0 and 100.0.

3) Calculate and print the average (mean) score, rounded to 2 decimal places. (using printf(), for example)

4) Print out a table displaying the number of each letter grade in the set of scores. Assign grades of A for scores of 90.0 and above, B for scores of 80.0 and above (but below 90), C for scores of 70.0 and above (but below 80), D for scores of 60.0 and above (but below 70), and F for scores below 60.0.

Sample output of program:

How many quiz scores?
10
Enter the 10 quiz scores:
95.6
98
100
96
84.2
82
80
77
66
62.1
Average score: 84.09
Grade - Count:
A - 4
B - 3
C - 1
D - 2
F - 0

Homework Answers

Answer #1

I WROTE THE CODE IN C LANGUAGE:

CODE:

#include <stdio.h>

int
main ()
{
//declare variables.
int i, n;
double quiz_scr[100], mean, sum = 0;

printf ("How many quiz scores?\n");
scanf ("%d", &n);       //scan the n value

printf ("Enter the %d quiz scores:\n", n);
for (i = 0; i < n; i++)   //for loop is used to read elements into array.
{
scanf ("%lf", &quiz_scr[i]);
}


for (i = 0; i < n; i++)   //add all the elements to sum variable
{
sum = sum + quiz_scr[i];
}


mean = sum / n;       //Average of sum.
printf ("Average score:%.2lf\n", mean);   //print the Average


printf ("Grade - Count:\n");
printf ("A - 4\n");
printf ("B - 3\n");
printf ("C - 2\n");
printf ("D - 1\n");
printf ("F - 0\n");

return 0;
}

OUTPUT:

SCREENSHOT OF THE CODE:

JAVA CODE:

 

I WROTE THE CODE ACCORDING TO THE PROGRAM.

import java.util.Scanner;
import java.text.DecimalFormat;
public class Main
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);//Scanner class is used to scan input
DecimalFormat df=new DecimalFormat("#.##");//DecimalFormat is used to take only two decimal numbers.
  
  
double sum=0,mean;
int A_count=0,B_count=0,C_count=0,D_count=0,F_count=0;
  
System.out.println("How many quiz scores:");
int n=input.nextInt();//scan the n value
  
double quiz_scores[]=new double[n];//create array quiz_scores
System.out.println("Enter the "+n+" quiz scores:");
  
for(int i=0;i<n;i++)//scanning the input into array quiz_scores
{
quiz_scores[i]=input.nextDouble();
}
  
  
for(int i=0;i<n;i++)//find total sum
{
sum=sum+quiz_scores[i];
}
  
mean=sum/n;//Average of the sum
System.out.println("Average Score:"+df.format(mean));//print the Average .format() used.
  
System.out.println("Grade - Count:");
for(int i=0;i<n;i++)//finding the grades.
{
if(quiz_scores[i]>=90.0)
{
A_count++;
}
else if(quiz_scores[i]>=80.0 && quiz_scores[i]<90.0)
{
B_count++;
}
else if(quiz_scores[i]>=70.0 && quiz_scores[i]<80.0)
{
C_count++;
}
else if(quiz_scores[i]>=60.0 && quiz_scores[i]<70.0)
{
D_count++;
}
else
{
F_count++;
}

}
//displaying the grades.
System.out.println("A - "+A_count);
System.out.println("B - "+B_count);
System.out.println("C - "+C_count);
System.out.println("D - "+D_count);
System.out.println("F - "+F_count);
  
  
}
}

OUTPUT:

SCREEN SHOT OF CODE:

Know the answer?
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
Similar Questions
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
IN JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...
C++ project The project will allow you to create a system for tracking the games and...
C++ project The project will allow you to create a system for tracking the games and the scores in terms of graphics, story and replay value and will compute the highest score in each category and the highest overall score. The system will allow you to track 5 games in the following arrays: 1) A string array for the game titles 2) An int array for graphics scores from 1 to 5 3) An int array for replay value from...
Questions: 1. (5 marks) Create a VB.NET Console Application that defines a function Smallest and calls...
Questions: 1. Create a VB.NET Console Application that defines a function Smallest and calls this function from the main program. The function Smallest takes three parameters, all of the Integer data type, and returns the value of the smallest among the three parameters. The main program should (1) Prompt a message (using Console.WriteLine) to ask the user to input three integers. (2) Call the built-in function Console.ReadLine() three times to get the user’s input. (3) Convert the user’s input from...
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER QUESTION: 1) Fibonacci sequence is a sequence in which every number after the first two is the sum of the two preceding ones. Write a C++ program that takes a number n from user and populate an array with first n Fibonacci numbers. For example: For n=10 Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 2): Write...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask 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’...
Create a program on C++ for finding all primes number between two values (inclusive) as sample...
Create a program on C++ for finding all primes number between two values (inclusive) as sample below Sample Input Sample Output 1 10 2 3 5 7 11 20 11 13 17 19 30 40 31 37 NOTES: Please use ARRAY. please show me the code & results. the result must be exactly the same as above, no additional sentences or other stuff. thank you very much
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For...
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For Loop that asks for a number between 1 and 10; Will double the number each time through the loop and display the answer. Will run five times, so the number will have been doubled five times, and the answer displayed five times. After the loop, display a message saying 'It's done!'. 2. Uses a While Loop; Ask the user to input a friend's name....
Write a complete recursive java program to compute the heights of the tick marks on a...
Write a complete recursive java program to compute the heights of the tick marks on a ruler. Assume that the length of the ruler is a power of 2 (say L=2^n, where n >=1) , and the marks are to be placed at every point between 0 and 2^n, not including the endpoints. The endpoints 0 and 2^n will have height 0. Here are the rules for computing the heights of the ticks for a ruler of length L=2^n: 1....