The actual computations aren't working properly when it comes to the remainder. Specifically the variable termLeft. Any suggestions?
package graduationplanner; import java.util.Scanner; import java.util.ArrayList; public class GraduationPlanner { public static void main(String[] args) { Scanner in = new Scanner(System.in); final int MINCU = 12; final int TUITIONCOST = 2890; //stores value for tuition cost per term final int TERMMONTHS = 6; //stores value for number of months in a term int sum = 0; System.out.println("Welcome to the Western Governor's University Graduation Planner! \nWe will calculate the number of terms you have left until graduation, \nalong with the amount of tuition you have left to pay. \nWe will also provide the number of months until graduation! \nLet's get started by asking a few questions."); System.out.println("How many CU's are you planning on taking per term?"); //Prompts user for the number of CU's per term int perTerm = in.nextInt(); //storing user input if (perTerm < MINCU){ //verification on positive input by user System.out.println("12 CU's are required per term. Try a higher number!"); System.out.println("How many CU's are required for your degree?"); perTerm = in.nextInt();} //stores corrected number //System.out.println(perTerm); ArrayList<Integer> leftCU = new ArrayList<>();{ System.out.println("Please enter one at a time the number of CU's for each class that is left to complete. Enter Q when done."); leftCU.add(in.nextInt()); while (in.hasNextInt()){ leftCU.add(in.nextInt());} for(int i=0; i < leftCU.size(); i++){ sum = sum + leftCU.get(i);} } //System.out.println(leftCU); //System.out.println(sum); System.out.println("The number of CU's left are: "+ leftCU); System.out.println("The sum of the number of CU's left are: " + sum); int tempLeft = sum/perTerm; //Calculates number of terms left int termLeft = 0; if ((tempLeft % 4) == 0){ termLeft = tempLeft;} else {termLeft = tempLeft + 1;} int totalTuition = termLeft * TUITIONCOST; //Calculates the amount of tuition left to pay int monthsLeft = termLeft * TERMMONTHS; //Calculates the number of months left System.out.println("Number of terms left is " + sum + " divided by " + perTerm + " equals " + termLeft); System.out.println("Total amount of tuition left is " + termLeft + " times " + TUITIONCOST + " equals " + totalTuition); System.out.println("Number of Months left is " + termLeft + " times " + TERMMONTHS + " equals " + monthsLeft); System.out.println("+----------------------------------------+"); System.out.println("|Number of Terms left is: " + termLeft + "|"); System.out.println("|Total amount of Tuition left is: " + totalTuition + "|"); System.out.println("|Number of Months left is: " + monthsLeft + "|"); System.out.println("+----------------------------------------+"); System.out.println("Thank you for using the WGU Graduation Planner"); } }