Skip to content
Advertisement

How to make a grading program using ConsoleIO in Java (***No Scanner***) [closed]

Write a Java application that takes in a number of grade scores (decimals allowed), and computes the average of them. Then print out a letter grade corresponding to the average; either A, B, C, D, or F. See examples below.

Use the following grading scale

At least 90: A otherwise at least 80: B otherwise at least 70: C otherwise at least 60: D otherwise: F

This is what the output should look like. How many grades will you be entering? 3 What is the next grade? 91.5 What is the next grade? 90.5 What is the next grade? 90 Here is the average: 90.66666666666667 This is an A.

here is what I have:

JavaScript

} }

Advertisement

Answer

First, make sure your JVM has any console attached to. System.console(); returns the unique Console object associatedwith the current Java virtual machine, if any.

System.console() returns a java.io.Console, which is the proper way to invoke it since Java5 (more or less..)

So you may be hitting a nullPointer if you execute it on a JVM without console.

That said, this is the code:

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement