import java.util.Scanner;
public class Section3_Projects {
public static void main (String[] args){
Scanner keyboard = new Scanner(System.in);
int Package;
int Course;
int Total;
System.out.println("Which of the packages do you want? \t " +"1,2, or 3?");
Package = keyboard.nextInt();
System.out.println("How many courses did you enroll in this month?");
Course = keyboard.nextInt();
if (Package == 1 && Course <= 2) {
System.out.println("Total cost is " + "$10");
}
else {
System.out.println("Total cost is " + "$" + (10+ (6 * (Course-2))));
//If-else 1
}
if (Package == 2 && Course <= 4) {
System.out.println("Total cost is " + "$12");
}
else {
System.out.println("Total cost is " + "$" +(12 + (4 * (Course-4))));
}//If-else 2
if(Package == 3 && Course <= 6) {
System.out.println("Total cost is " + "$15");
}
else {
System.out.println("Total cost is " + "$" +(15+(3*(Course-6))));
}//If-else 3
}//end main
}
Hi all, first post on this forum and hoping someone code help me with my a work problem below. When I ran this code with the following input, I get three "Total cost" coming out:
Input/Output
Which of the packages do you want? 1,2, or 3?
3
How many courses did you enroll in this month?
10
Total cost is $58
Total cost is $36
Total cost is $27
I think I am missing something so that only one correct "Total cost" should be showing. Any help is appreciated. Thanks!