Skip to content

Instantly share code, notes, and snippets.

@Aroueterra
Last active May 10, 2021 12:20
Show Gist options
  • Save Aroueterra/a953e096e4408364e563f5664c75d99c to your computer and use it in GitHub Desktop.
Save Aroueterra/a953e096e4408364e563f5664c75d99c to your computer and use it in GitHub Desktop.
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