In: Computer Science
I want to know how can I fix this program so it can work properly....can someone run it and give me the fixed version but do not the entire program bear with this one please and thanks in advance!!!!!
import java.util.Scanner;
public class ifPractice
{
public static void main(String[] args)
{
Scanner KB = new Scanner(System.in);
{
double option;
double option02;
double stu_gradeTest01;
double stu_gradeTest02;
double stu_gradeTest03;
double final_grade;
{
System.out.println("Enter #1 to see what test to grade first, #2
for student's average, #3 " +
"to see what is the final grade for the student: ");
option = KB.nextDouble();
if(option == 1)
{
System.out.println("Let's see which exam to grade
first....");
System.out.println("Now please choose #4 for first exam; #5 for
second exam; #6 for final exam: ");
option02 = KB.nextDouble();
if(option02 == 4)
{
System.out.println("Grade exam one: ");
stu_gradeTest01 = KB.nextDouble();
System.out.println("The first exam: " + stu_gradeTest01);
}
else if(option02 == 5)
{
System.out.println("Grade exam two: ");
stu_gradeTest02 = KB.nextDouble();
System.out.println("The second exam: " + stu_gradeTest02);
}
else if(option02 == 6)
{
System.out.println("Grade exam three: ");
stu_gradeTest03 = KB.nextDouble();
System.out.println("The third exam: " + stu_gradeTest03);
}
else
System.out.println("Invalid entry.... program in lockdown until
further notice....");
}
else if(option == 2)
{
System.out.println("These are all of the grades: ");
stu_gradeTest01 = KB.nextDouble();
stu_gradeTest02 = KB.nextDouble();
stu_gradeTest03 = KB.nextDouble();
final_grade = (stu_gradeTest01 + stu_gradeTest02 +
stu_gradeTest03)/3.0;
System.out.println("The final grade is: " + final_grade);
}
else
System.out.println("Invalid entry...llocking system
down....");
}
else if(option == 3)
{
System.out.println("The final grade the student got was: ");
final_grade = KB.nextDouble();
if(final_grade >= 90)
{
System.out.print("A");
final_grade = KB.nextDouble();
}
else if(final_grade >= 80 )
{
System.out.print("B");
final_grade = KB.nextDouble();
}
else if(final_grade >= 70)
{
System.out.print("C");
final_grade = KB.nextDouble();
}
else if(final_grade <= 65)
{
System.out.println("Your are failing");
final_grade = KB.nextDouble();
}
else if(final_grade >= 64)
{
System.out.println("F");
final_grade = KB.nextDouble();
}
else
{
System.out.println("Invalid enry.....lllocking down....");
}
}
else
System.out.println("Invalid entry");
}
}
}
Note: Could you plz go through this code and let me know if u
need any changes in this.Thank You
_________________
// IfPractice.java
import java.util.Scanner;
public class IfPractice {
public static void main(String[] args) {
Scanner KB = new
Scanner(System.in);
{
int option,
option02;
double
stu_gradeTest01;
double
stu_gradeTest02;
double
stu_gradeTest03;
double
final_grade;
System.out.println("Enter #1 to see what test to grade first, #2
for student's average, #3 "
+ "to see what is the final grade for the
student: ");
option =
KB.nextInt();
if (option ==
1) {
System.out.println("Let's see which exam to
grade first....");
System.out.println("Now please choose #4 for
first exam; #5 for second exam; #6 for final exam: ");
option02 = KB.nextInt();
if (option02 == 4) {
System.out.println("Grade
exam one: ");
stu_gradeTest01 =
KB.nextDouble();
System.out.println("The first
exam: " + stu_gradeTest01);
} else if (option02 == 5) {
System.out.println("Grade
exam two: ");
stu_gradeTest02 =
KB.nextDouble();
System.out.println("The
second exam: " + stu_gradeTest02);
} else if (option02 == 6) {
System.out.println("Grade
exam three: ");
stu_gradeTest03 =
KB.nextDouble();
System.out.println("The third
exam: " + stu_gradeTest03);
} else
System.out.println("Invalid
entry.... program in lockdown until further notice....");
}
else if
(option == 2) {
System.out.println("These are all of the grades:
");
stu_gradeTest01 = KB.nextDouble();
stu_gradeTest02 = KB.nextDouble();
stu_gradeTest03 = KB.nextDouble();
final_grade = (stu_gradeTest01 + stu_gradeTest02
+ stu_gradeTest03) / 3.0;
System.out.println("The final grade is: " +
final_grade);
} else if
(option == 3) {
System.out.println("The final grade the student
got was: ");
final_grade = KB.nextDouble();
if (final_grade >= 90) {
System.out.print("A");
final_grade =
KB.nextDouble();
} else if (final_grade >= 80) {
System.out.print("B");
final_grade =
KB.nextDouble();
} else if (final_grade >= 70) {
System.out.print("C");
final_grade =
KB.nextDouble();
} else if (final_grade <= 65) {
System.out.println("Your are
failing");
final_grade =
KB.nextDouble();
} else if (final_grade >= 64) {
System.out.println("F");
final_grade =
KB.nextDouble();
} else {
System.out.println("Invalid
enry.....lllocking down....");
}
} else
System.out.println("Invalid entry");
}
}
}
______________________
Output#1:
Enter #1 to see what test to grade first, #2 for
student's average, #3 to see what is the final grade for the
student:
1
Let's see which exam to grade first....
Now please choose #4 for first exam; #5 for second exam; #6 for
final exam:
4
Grade exam one:
45
The first exam: 45.0
________________________
Output#2:
Enter #1 to see what test to grade first, #2 for
student's average, #3 to see what is the final grade for the
student:
2
These are all of the grades:
56
78
89
The final grade is: 74.33333333333333
_______________Could you plz rate me well.Thank You