Here is the code I have so far but I am unsure where to go f

Here is the code I have so far, but I am unsure where to go from here.

import java.util.Scanner;

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

double exam1;
double exam2;
double exam3;
double average;
String name;

char grade;

name = input.next();
exam1 = input.nextDouble();
exam2 = input.nextDouble();
exam3 = input.nextDouble();
average = (exam1 + exam2 + exam3) / 3 ;
grade = \' \' ;

if (average >= 90){
grade = (\'A\');
}
else
if (average >= 80){
grade = (\'B\');
}
else
if (average >= 70){
grade = (\'C\');
}
else
if (average >= 60){
grade = (\'D\');
}
else
if (average >= 0){
grade = (\'F\');
}

System.out.println(\"Name: \" + name);
input.next();
System.out.println(\"Exam 1: \" + exam1);
input.nextDouble();
System.out.println(\"Exam 2: \" + exam2);
input.nextDouble();
System.out.println(\"Exam 3: \" + exam3);
input.nextDouble();
System.out.println(\"Avg: \" + average);

It compiles but there is no output. The values can be input by the user as well as read in from a .dat file. Our teacher told us to use Scanner.next() to read in a space at a time from the .dat file, but I am unsure where to put that. Thanks.

Program 2: Grading System Description Write a program that calculates a student\'s exam average and course grade. Input will be read from a single file that contains a student\'s name (single string with no whitespace) and 3 separate exam scores. Your program should print the student\'s name, each exam score, the average score, and a letter grade based on the following scale: A: 90% or higher B: 80% or higher C: 70% or higher D: 60% or higher F: below 60 If at least one exam was failed (below 60%) and the student has a passing grade (D or higher), print the following message: least one exam was failed. Make-up work may be required to pass \"At the class. Sample Input/Output Sample input 1 Mars, Bruno 70 81 92 Execution Mars, Bruno Exam 1 70.0 Exam 2 81.0 Show all

Solution

I have done by entering values manually.

package studentgrade;

import java.util.Scanner;

public class StudentGrade {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double exam1;
double exam2;
double exam3;
double average;
String name;
char grade;
System.out.println(\"Enter student name:\");
name = input.next();
System.out.println(\"Enter student marks:\");
exam1 = input.nextDouble();
exam2 = input.nextDouble();
exam3 = input.nextDouble();
average = (exam1 + exam2 + exam3) / 3 ;
grade = \' \' ;
if(exam1 < 60 || exam2 < 60 || exam3 < 60){
System.out.println(\"At least one exam was failed. Make-up work may be required to pass the exam\");
System.exit(0);
}
else{
if (average >= 90){
grade = (\'A\');
}
else
if (average >= 80){
grade = (\'B\');
}
else
if (average >= 70){
grade = (\'C\');
}
else
if (average >= 60){
grade = (\'D\');
}
else
if (average >= 0 && average < 60){
grade = (\'F\');
  
}
  
}
System.out.println(\"Name: \" + name);
//input.next();
System.out.println(\"Exam 1: \" + exam1);
//input.nextDouble();
System.out.println(\"Exam 2: \" + exam2);
//input.nextDouble();
System.out.println(\"Exam 3: \" + exam3);
//input.nextDouble();
System.out.println(\"Avg: \" + average);
System.out.println(\"Grade: \"+grade);
}
  
}

Here is the code I have so far, but I am unsure where to go from here. import java.util.Scanner; public class prog2 { public static void main(String[] args) { S
Here is the code I have so far, but I am unsure where to go from here. import java.util.Scanner; public class prog2 { public static void main(String[] args) { S
Here is the code I have so far, but I am unsure where to go from here. import java.util.Scanner; public class prog2 { public static void main(String[] args) { S

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site