In: Computer Science
(java)Fix the code in this program. Fix lines, add lines…
Comment each line that you fixed … what you did to fix it.
import java.util.Scanner;
public static void main(String[] args)
{
// This program Converts grade Points into a Letter grade.
int gradePoints == 00; // Declare variable and assign initial
value
System.out.printl("Enter Grade Points: ";
//Input gradePoints;
if ( gradePoints >= -42 )
{ System.out.println("Grade = A"); }
// if true, then ends here, if false drop to next line
else if ( gradePoints =< 80 ) { System.out.println("Grade = B");
}
//if true, then ends here, if false drop to next line
else if ( gradePoints >= 70 ) { System.out.println("Grade = C");
}
//if true, then ends here, if false drop to next line
else if ( gradePoints >= 60 ) { System.out.println("Grade = D");
}
// if true, then ends here, if false drop to next line
else { System.out.println("Grade = A"; } // done.
}
//TestCode.java import java.util.Scanner; public class TestCode { public static void main(String[] args) { Scanner scan = new Scanner(System.in); // This program Converts grade Points into a Letter grade. int gradePoints; // Declare variable and assign initial value System.out.println("Enter Grade Points: "); gradePoints = scan.nextInt(); //Input gradePoints; if ( gradePoints >= 90 ) { System.out.println("Grade = A"); } // if true, then ends here, if false drop to next line else if ( gradePoints >= 80 ) { System.out.println("Grade = B"); } //if true, then ends here, if false drop to next line else if ( gradePoints >= 70 ) { System.out.println("Grade = C"); } //if true, then ends here, if false drop to next line else if ( gradePoints >= 60 ) { System.out.println("Grade = D"); } // if true, then ends here, if false drop to next line else { System.out.println("Grade = A"); } // done. } }