gramming Language: Java Direction: Write a program to determine the number of PASSED and FAILED out of 15 inputted names with the corresponding grade. Restrict the inputted grade for each name in the range of 50 to 100, in which 75 is the passing grade. If the inputted gr

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter5: Looping
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
100%

Programming Language: Java

Direction: Write a program to determine the number of PASSED and FAILED out of 15 inputted names with the corresponding grade. Restrict the inputted grade for each name in the range of 50 to 100, in which 75 is the passing grade. If the inputted grade is not on the range, the program will remind the user of a message for the accepted range for the grade and allows the user to re-enter a grade.

 

NOTE: MUST ADD COMMENTS

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

please help me fix the error im using java eclipse as my IDE

Main.java X
1 public class Main {
20
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 }
public static void main(String[] args) {
//initialize the variables
}
int pass = 0;
int fail = 0;
int numOfNames = 15;
//create a for loop to prompt the user 15 times
for (int i = 0; i < numOfNames; i++) {
//prompt the user to enter a name
System.out.print("Please enter the name: ");
String name = System.console().readLine();
//prompt the user to enter the grade
System.out.print("Please enter the grade: ");
int grade = Integer.parseInt(System.console().readLine());
//check if the grade is in the accepted range
while (grade < 50 || grade > 100) {
//if the grade is not in range, prompt the user to enter a valid grade
System.out.print("Please enter a valid grade between 50 and 100: ");
grade = Integer.parseInt(System.console().readLine());
}
//if the grade is 75 or greater, increment the pass counter
if (grade >= 75) {
pass++;
}
//otherwise increment the fail counter
else {
fail++;
}
}
//print the results
System.out.println("Number
System.out.println("Number
of PASSED:
+ pass);
of FAILED: " + fail);
Transcribed Image Text:Main.java X 1 public class Main { 20 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 } public static void main(String[] args) { //initialize the variables } int pass = 0; int fail = 0; int numOfNames = 15; //create a for loop to prompt the user 15 times for (int i = 0; i < numOfNames; i++) { //prompt the user to enter a name System.out.print("Please enter the name: "); String name = System.console().readLine(); //prompt the user to enter the grade System.out.print("Please enter the grade: "); int grade = Integer.parseInt(System.console().readLine()); //check if the grade is in the accepted range while (grade < 50 || grade > 100) { //if the grade is not in range, prompt the user to enter a valid grade System.out.print("Please enter a valid grade between 50 and 100: "); grade = Integer.parseInt(System.console().readLine()); } //if the grade is 75 or greater, increment the pass counter if (grade >= 75) { pass++; } //otherwise increment the fail counter else { fail++; } } //print the results System.out.println("Number System.out.println("Number of PASSED: + pass); of FAILED: " + fail);
Please enter the name: Exception in thread "main"
at Main.main (Main.java:11
java.lang.NullPointerException:
Cannot invoke "java.io.Console.read
Transcribed Image Text:Please enter the name: Exception in thread "main" at Main.main (Main.java:11 java.lang.NullPointerException: Cannot invoke "java.io.Console.read
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning