Вот мой полный ответ.Осталось только то, что я не знаю, как иметь 3 знака после запятой ... Я обновлю, когда что-нибудь придумаю.
import java.util.*;
import java.text.*;
import java.lang.Math;
public class Project1_Trial3 {
public static void main(String args[])
{
Scanner scanner = new Scanner(System.in);
//Input the term
System.out.println("Please enter the term of your grade calculation (for example, Fall 2015): ");
String term = scanner.nextLine();
//Input the number of courses that the student is enrolled in
System.out.println("Please enter the number of courses that you are enrolled in "+term+": ");
int numberofcourses = scanner.nextInt();
//Declaration
String ClassName[] = new String[numberofcourses];
String Description[] = new String[numberofcourses];
String grade[] = new String[numberofcourses];
float Units[] = new float[numberofcourses];
double gradeValue = 0;
float finalgrade[] = new float[numberofcourses];
float totalunits = 0;
float fail = 0;
float pass = 0;
float totalgradepoints = 0;
float gpa = 0;
String standing = null;
//Arrays for class number, description, units, grade, grade point
//Here, input class number, description, units, and grade
for(int i = 0; i < numberofcourses; i++)
{
scanner.nextLine();
System.out.println("Please enter your #"+(i+1)+" class name: ");
ClassName[i] = scanner.nextLine();
System.out.println("Please enter your #"+(i+1)+" class description: ");
Description[i] = scanner.nextLine();
System.out.println("Please enter your #"+(i+1)+" class units: ");
Units [i] = scanner.nextInt();
scanner.nextLine();
System.out.println("Please enter your #"+(i+1)+" class grade: ");
grade[i] = scanner.nextLine();
if (grade[i].equals ("A"))
gradeValue= 4.00;
else if (grade[i].equals("A-"))
gradeValue= 3.67;
else if (grade[i].equals("B+"))
gradeValue = 3.33;
else if (grade[i].equals("B"))
gradeValue = 3.00;
else if (grade[i].equals ("B-"))
gradeValue = 2.67;
else if (grade[i].equals("C+"))
gradeValue = 2.33;
else if (grade[i].equals("C"))
gradeValue = 2.00;
else if (grade[i].equals ("D+"))
gradeValue = 1.33;
else if (grade[i].equals ("D"))
gradeValue = 1.00;
else if (grade[i].equals ("F"))
gradeValue = 0;
else
System.out.println ("Invalid Grade");
finalgrade[i] = (float) (gradeValue * Units[i]);
//Get the total number of units
totalunits += Units[i];
//Get the total grade points
totalgradepoints += finalgrade[i];
if (grade[i].equals("F"))
fail = Units[i];
pass = totalunits - fail;
gpa = totalgradepoints / totalunits;
}
//Get status
if (gpa > 2.0)
standing = "Good standing";
else if (1.0 < gpa | gpa < 1.999)
standing = "On probation";
else
standing = "Dismissed";
//Round to 3 decimals and get final results
//Finally, print out the report
//Print out the heading
System.out.println("Class Grades - "+term+" Term");
System.out.println("Office Grades");
//Print out the table
System.out.println(String.format("%20s %7s %25s %7s %10s %7s %7s %10s %10s", "Class", "|", "Description", "|", "Units", "|", "Grade", "|", "Gradepoint"));
System.out.println(String.format("%s", "-------------------------------------------------------------------------------------------------------------------------------------"));
for(int i = 0; i < numberofcourses; i++)
{
DecimalFormat format = new DecimalFormat("#.#####");
format.format(totalunits);
format.format(fail);
format.format(totalgradepoints);
format.format(gpa);
System.out.println(String.format("%20s %7s %-25s %7s %10s %7s %-7s %10s %-10s", ClassName[i], "|", Description[i], "|", Units [i], "|", grade[i], "|", finalgrade[i]));
}
System.out.println("Term Statistics - "+term+" Term");
System.out.println(String.format("%s", "-----------------------------------------------------------------------------------------------"));
System.out.println(String.format("%40s %7s %25s", "", "|", "From Enrollment"));
System.out.println(String.format("%40s %7s %25s", "", "|", ""));
System.out.println(String.format("%40s %7s %25s", "Units Towards GPA:", "|", ""));
System.out.println(String.format("%40s %7s %25s", "Taken", "|", totalunits));
System.out.println(String.format("%40s %7s %25s", "Passed", "|", pass));
System.out.println(String.format("%s", "-----------------------------------------------------------------------------------------------"));
System.out.println(String.format("%40s %7s %25s", "GPA Calculation", "|", ""));
System.out.println(String.format("%40s %7s %25s", "Total Grade Points", "|", totalgradepoints));
System.out.println(String.format("%40s %7s %25s", "/ Units Taken Toward GPA", "|", totalunits));
System.out.println(String.format("%s", "-----------------------------------------------------------------------------------------------"));
System.out.println(String.format("%40s %7s %25s", "= GPA", "|", gpa));
System.out.println(String.format("%40s %7s %25s", "Status", "|", standing));
}
}