Last active
May 10, 2021 12:20
-
-
Save Aroueterra/a953e096e4408364e563f5664c75d99c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.ArrayList; | |
public class museum { | |
public static void main(String args[]) { | |
Scanner input = new Scanner(System.in); | |
ArrayList<Integer> cost = new ArrayList<Integer>(); | |
int age=-1; | |
while(age != 0){ | |
System.out.println("How old are you?"); | |
age = input.nextInt(); | |
int temp = 0; | |
if(age>=65){ | |
cost.add(70); | |
}else if((age>=3)&&(age<=12)){ | |
cost.add(50); | |
}else if(age<=2){ | |
cost.add(0); | |
}else{ | |
cost.add(100); | |
} | |
} | |
int sum=0; | |
for(int n:cost){ | |
sum+=n; | |
} | |
System.out.println("Total admission cost is " + sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment