//Name: penis
import javax.swing.*;
import java.util.*;
import static java.lang.System.*;
public class Methods {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int grade1 = 0;
int grade2 = 0;
int grade3 = 0;
int sum = 0;
double average = 0.0;
System.out.println(" enter grade one * ");
grade1 = reader.nextInt();
out.println(" *enter grade two * ");
grade2 = reader.nextInt();
out.println(" *enter grade three * ");
grade3 = reader.nextInt();
sum = findSum(grade1, grade2, grade3);
average = findAverage(sum);
System.out.println(" Your average = " + average);
System.out.println();
comment(average);
// g1, g2, g3 bool (does nothing)
higher(grade1, grade2, grade3, false);
} // end of main
//******************************************************************** 1
public static int findSum(int g1, int g2, int g3) {
return g1 + g2 + g3;
}
//********************************************************************
public static double findAverage(int sum) {
return sum / 3.0;
}
//**************************************************************
// Prints a comment based on the average
public static void comment(double myAvg) {
if (myAvg >= 90) {
System.out.println("A!");
} else if (myAvg >= 80) {
System.out.println("B!");
} else if (myAvg >= 70) {
System.out.println("C!");
} else if (myAvg >= 60) {
System.out.println("D!");
} else {
System.out.println("F!");
}
}
//**************************************************************
// Return the largest of the three values
public static int higher(int g1, int g2, int g3, boolean showAll) {
int[] array = {g1, g2, g3};
int temp;
// System.out.println("Array.length: " + array.length);
for (int i = 0; i < array.length; i++) {
for (int j = i + 1; j < array.length; j++) {
if (array[j] > array[i])
{
temp = array[j];
array[j] = array[i];
array[i] = temp;
// if (showAll) {
System.out.println("Grades (sorted in ascending order): ");
for (i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
/* } else {
System.out.println("Highest Grade: \n" + array[i]);
} */
// Can't figure out how to print just a single piece from an array in java lol (but i can do it in Lua)
}
}
}
return 0;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: