Question

In java : Write a program that will provide important statistics for the grades in a...

In java :

Write a program that will provide important statistics for the grades in a class. The program will utilize a for-loop to read ten floating-point grades from user input. Include code to prevent an endless loop. Ask the user to enter the values, then print the following data:

  • Average
  • Maximum
  • Minimum

Homework Answers

Answer #1

Please let me know if anything is required

import java.util.Scanner;

public class Main
{
   public static void main(String[] args) {
  
   Scanner input = new Scanner(System.in);
     
  
   float sum=0,minimum=9999999,maximum=0; //initializing the minimum , maximum and sum values
   for(int i=0;i<10;i++) //loop for taking 10 grade points and also calculating minimum,maximum and Average grade points
   {
  
       System.out.print("Enter grade : ");
   float myFloat = input.nextFloat(); //taking the grade point from the user
  
   sum = sum+myFloat; //calculating the sum of the all grade points
  
   if(myFloat<minimum) //checking if the grade point is less than the minimum
   {
   minimum = myFloat; //if so then replacing the minimum with the grade point
   }
  
   if(myFloat>maximum)//checking if the grade point is greater than the maximum
   {
   maximum = myFloat; //if so then replacing the maximum with the grade point
   }
  
   }
  
   System.out.println("Maximum is " + maximum); //printing the minimum of all grades
   System.out.println("minimum is " + minimum); //printing the maximum of all grades
   System.out.println("Average is " + sum/10.0); //printing the Average of all grades
   }
}

Enter grade : 1.5 Enter grade : 2.5 Enter grade : 4.5 Enter grade : 3.5 Enter grade : 5.5 Enter grade : 7.5 Enter grade : 6.5 Enter grade : 8.5 Enter grade : 10.5 Enter grade : 9.5 Maximum is 10.5 minimum is 1.5 Average is 6.0

1 import java.util.Scanner; 3 public class Main public static void main(String[] args) { Scanner input = new Scanner(System.in); float arr[] = new float(10); //taking the float array to store the grade points float sum=,minimum=9999999, maximum 0; //initializing the minimum, maximum and sum values for(int i 0;i<10; i++) //loop for taking 10 grade points and also calculating minimum, maximum and Average grade points System.out.print("Enter grade : "); float myFloat = input.nextFloat(); //taking the grade point from the user arr[i] = myFloat; //storing the grade point into the array sum = sum myFloat; //calculating the sum of the all grade points if(myFloat minimum) //checking if the grade point is less than the minimum minimum = myFloat; //if so then replacing the minimum with the grade point Input Enter grade : 1.5 Enter grade : 2.5 Enter grade : 4.5 Enter grade : 3.5 Enter grade : 5.5 Enter grade : 7.5 Enter grade : 6.5

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
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.,...
(8 marks) Write a program to ask user to input an integer and display the special...
Write a program to ask user to input an integer and display the special pattern accordingly. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use loop statements (for, while or do-while). Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("-"); // print # System.out.print("+"); // print + System.out.println(); // print a newline Your code must work exactly like the following example (the text in bold...
Write code in JAVA Write a program that will output a right triangle based on user...
Write code in JAVA Write a program that will output a right triangle based on user specified input height (int) and specified input symbol (char).The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches specified input height. Output a space after each user-specified character, including after the line's last user-specified character. Hint: Use a nested for loop. Ex:If the input...
Write a C++ program. 1) Write a program that writes the grades for 3 students. Declare...
Write a C++ program. 1) Write a program that writes the grades for 3 students. Declare a variable of type ofstream which is used to output a stream into a file: ofstream output; // output is the name of the variable Prompt the user to input values for the grades of 3 students. Use the output operator (<<) to write the grades into grades.txt: output << grade1 << " " << grade2 << " " << grade3 << endl; You...
IN JAVA PLEASE write code to MERGESORT an array of user inputted OBJECTS you have two...
IN JAVA PLEASE write code to MERGESORT an array of user inputted OBJECTS you have two different classes in the program being made as objects in the main (Bunny class and Dog Class). ask the user "what kind of animal would you like to sort?" user chooses the type of animal (bunny or dog), then you ask the user how big would you like the array of animals to be (maximum array size = 20)? and then you ask what...
In this lab, you complete a partially prewritten C++ program that uses an array. The program...
In this lab, you complete a partially prewritten C++ program that uses an array. The program prompts the user to interactively enter eight batting averages, which the program stores in an array. The program should then find the minimum and maximum batting average stored in the array as well as the average of the eight batting averages. The data file provided for this lab includes the input statement and some variable declarations. Comments are included in the file to help...
Create a JAVA program to display the numbers 1-10. Although you could program a solution that...
Create a JAVA program to display the numbers 1-10. Although you could program a solution that has ten lines of code like the following, think about why this would be a bad idea when developing a programming solution: Print 1 Print 2 Print 3 Print 4 (continued to Print 10) Note: Examples for Java programs (Loop and no loop) programs are in the "Important Documents" folder / Module 6.
Write a Java program that prompts the user to input a word (String). The program must...
Write a Java program that prompts the user to input a word (String). The program must print the reversed word with all consecutive duplicate characters removed. The program must contain the following classes: - The StackX class (you can use the Java Stack class). - The Reverse class which must contain a private data field called “word” of type string, a constructor, and a void method called revNoDup(). The revNoDup() method must reverse the word and remove the consecutive duplicate...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an...
Binary Search Tree Code in Java Write a program that prompts user to enter however many...
Binary Search Tree Code in Java Write a program that prompts user to enter however many numbers they want to add to the binary search tree. Then have the user input numbers until the tree contains that many elements. If the user enters a number that already exists in the tree, then a message should be displayed "Number is already in the tree". Once all elements are added to the tree print its contents in sorted order. Assume all user...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT