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
Create a Python program that populates an array variable whose values(at least 5) are input by...
Create a Python program that populates an array variable whose values(at least 5) are input by the user. It should then perform some modification to each element of array using a loop and then display the modified array in a second loop. Include Header comments in your program that describe what the program does.
Java... Write a class named TestScores. The class constructor should accept an array of test scores...
Java... Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException. Demonstrate the class in a program (create a Driver class in the same file). The program should ask the user to input the number of test scores to...
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 MIPS ASSEMBLY Macro File: Create macros to print an int, print a char, print a...
IN MIPS ASSEMBLY Macro File: Create macros to print an int, print a char, print a string, get a string from the user, open file, close file, read file, and allocate heap memory. You can use more macros than these if you like. Main Program File: Allocate 1024 bytes of dynamic memory and save the pointer to the area. The main program is a loop in which you ask the user for a filename. If they enter nothing for the...
Java: A teacher has five students who have taken four tests. The teacher uses the following...
Java: A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores: Test Score Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D 0–59 F Write a class that uses a String array (or an ArrayList object) to hold the five students’ names, an array of five characters to hold the five students’ letter...
C++ needs to output all of the name of the students not just first Write a...
C++ needs to output all of the name of the students not just first Write a program which uses an array of string objects to hold the five students' full names (including spaces), an array of five characters to hold each student's letter grade, a multi-dimensional array of integers to hold each of the five student's four test scores, and an array of five doubles to hold each student's average test score. The program will use a function to allow...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input file has an unknown number of numeric values(could be empty too).Read the numbers from the input fileand store even numbers in one arrayand odd numbers in another array.Create menu options to Display count of even numbers, count of odd numbersand the sum values in each array Determine the average of each array Determine the median of each array Sort each array in ascending order(use...
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...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT