Ask Question

How to hold numeric ranges and corresponding letter grade will be stored in a file java

+1
Answers (1)
  1. 12 March, 01:41
    0
    Print the grades on this Logic, this is logic for program and code is written under explanation.

    If the average of marks is > = 80 then prints Grade 'A'

    If the average is = 70 then prints Grade 'B'

    If the average is = 60 then prints Grade 'C'

    else prints Grade 'D'

    Explanation

    import java. util. Scanner;

    public class JavaGradeProgram

    {

    public static void main (String args[])

    {

    / * This program assumes that the student has 6 subjects that's why I have created the array of size 6. You can change this as per the requirement. * /

    int marks[] = new int[6];

    int i;

    float total=0, avg;

    Scanner scanner = new Scanner (System. in);

    for (i=0; i<6; i++) {

    System. out. print ("Enter Marks of Subject" + (i+1) + ":");

    marks[i] = scanner. nextInt ();

    total = total + marks[i];

    }

    scanner. close ();

    Calculate Average Here:

    avg = total / 6;

    if (avg >=80)

    {

    system. out. print ("A");

    }

    else if (avg>=70 && avg <=80)

    {

    system. out. print ("B");

    }

    else if (avg>=60 && avg <=70)

    {

    system. out. print ("C");

    }

    else

    {

    system. out. print ("D");

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “How to hold numeric ranges and corresponding letter grade will be stored in a file java ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers