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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education