I'm writing basically my first program for school. I've written small ones, following instructions, but this is the most vague. I'm having issues. I can't figure out what the error means. I'm not done with the code, but I think the ArrayList is throwing me off. I'm trying to gather user input and sum the total. Here's the code:
package graduationplanner; import java.util.ArrayList; import java.util.Scanner; import java.lang.Double; public class GraduationPlanner { public static void main(String[] args) { Scanner in = new Scanner(System.in); 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 required for your degree?"); //Prompts user for the total number of CU's for degree and stores in variable double totalCU = in.nextDouble(); //storing user input if (totalCU <= 0){ //verification on positive input by user System.out.println("That's not right! Enter a number higher than zero!"); System.out.println("How many CU's are required for your degree?"); totalCU = in.nextDouble(); //stores corrected number } //System.out.println(totalCU); //Outputting number entered for check double sum = 0; ArrayList<Double> leftCU = new ArrayList<>(); { System.out.println("Please enter the number of CU's for each class that is left to complete, Q to quit:"); double number = 0; number = Integer.parseInt(in.nextLine()); if (number <= 0); { System.out.println("The number of credits must be greater than zero!"); System.out.println("Please enter the number of CU's for each class that is left to complete, Q to quit."); } while (in.hasNextDouble()) { leftCU.add(in.nextDouble()); } for (int i = 0; i < leftCU.size(); i++) { sum =+ leftCU.get(i); } System.out.println("Total credits remaining: " + sum); } System.out.println("And what's the number of CU's left for just this term?"); //Prompts user for CUs left for term double cuLeftTerm = in.nextDouble(); //storing user input if (cuLeftTerm < 0) { System.out.println("Please enter a positive number please."); System.out.println("And what's the number of CU's left for just this term?"); cuLeftTerm = in.nextDouble(); //stores corrected number } final double tuitionCost = 2890; //stores value for tuition cost per term final double termMonths = 6; //stores value for number of months in a term final double minCUs = 12; //stores value for number of CUs required in a term double termLeft = sum/minCUs; //Calculates number of terms left double totalTuition = termLeft * tuitionCost; //Calculates the amount of tuition left to pay double monthsLeft = termLeft * termMonths; //Calculates the number of months left 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"); } }