Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static Scanner userInput = new Scanner(System.in);
- public static void main(String[] args){
- System.out.println("Type your name");
- if(userInput.hasNextLine()){
- String stringEntered = userInput.nextLine();
- System.out.println("Your name is: " + stringEntered);
- System.out.println("Hi " + stringEntered + ", how old are you?");
- int ageEntered = userInput.nextInt();
- if(ageEntered < 18){
- System.out.println("Sorry, " + stringEntered + ", You are unable to vote, or buy alcohol and cigarettes");
- }else if(ageEntered >= 18 && ageEntered <= 20){
- System.out.println("You are able to buy cigarettes, and vote.");
- }else{
- System.out.println("You are able to buy cigarettes, alcohol, and vote.");
- if(ageEntered >= 21) {
- System.out.println("Do you wanna to see something cool?");
- String answer = userInput.nextLine();
- if(answer.equalsIgnoreCase("yes")) {
- }else if(answer.equalsIgnoreCase("no")){
- System.out.println("Well, thanks anyways. Goodbye.");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement