Knowee
Questions
Features
Study Tools

evelop a Java program that calculates the average of three floating-pointnumbers and displays a grade based on the average.

Question

evelop a Java program that calculates the average of three floating-pointnumbers and displays a grade based on the average.

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Java program that calculates the average of three floating-point numbers and displays a grade based on the average.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("Enter three floating-point numbers:");
        float num1 = input.nextFloat();
        float num2 = input.nextFloat();
        float num3 = input.nextFloat();

        float average = (num1 + num2 + num3) / 3;

        System.out.println("The average is: " + average);

        if (average >= 90) {
            System.out.println("Grade: A");
        } else if (average >= 80) {
            System.out.println("Grade: B");
        } else if (average >= 70) {
            System.out.println("Grade: C");
        } else if (average >= 60) {
            System.out.println("Grade: D");
        } else {
            System.out.println("Grade: F");
        }
    }
}

This program works as follows:

  1. It prompts the user to enter three floating-point numbers.
  2. It calculates the average of these numbers.
  3. It prints the average.
  4. It checks the average and prints the corresponding grade. If the average is 90 or above, it prints "Grade: A". If it's 80 or above but less than 90, it prints "Grade: B", and so on. If the average is less than 60, it prints "Grade: F".

This problem has been solved

Similar Questions

import java.util.Scanner; public class Test1 { public static void main(String[] args) {     Scanner input = new Scanner(System.in);     System.out.print("Enter three numbers: ");     float number1 = input.nextInt();     float number2 = input.nextInt();     float number3 = input.nextInt();     float number4 = input.nextInt();     // Compute average     double average = (number1 + number2 + number3 + number4) / 4;     // Display result     System.out.println(average);   } }  When a user enters 1   2   3  4 during the program execution what will be the exact output?  Group of answer choices2.02.53.0The program gives an error.

Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F

Single File Programming QuestionProblem StatementJamie is managing a school and is looking to find out the number of students in the class based on the sum of their scores and the average score.He wants to design a program that takes the average score and sum of scores as input and outputs the calculated number of students in the class using pointers.Input format :The first line of input consists of an integer value n, representing the sum of scores.The second line of input consists of a floating-point value f, representing the average score.Output format :The output displays the calculated number of students in the class.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ n ≤ 1051.0 ≤ f ≤ 100.0Sample test cases :Input 1 :187575.45Output 1 :24Input 2 :20010.25Output 2 :19Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.Marks : 10Negative Marks : 0WhitelistSet 1:*

Write a program that repeatedly asks for numbers. When the user enters 0, the program prints the average of all numbers entered (excluding the 0) accurate to two decimal places and exits.

code this in java using patterns: Specification: Read in integers until the user enters -1. If there was at least one integer, show the average value.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.