Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package project;
- import java.util.Scanner;
- public class Assignment2 {
- public static void main(String[] args) {
- int flag = 0;
- Scanner scanner = new Scanner(System.in);
- System.out.println("Welcome. What is your name?");
- String name = scanner.nextLine();
- System.out.println("Hello " + name + "." + " Try your best to crack the code!");
- while(flag == 0) {
- System.out.println("PHASE 1"); //phase 1
- System.out.println("Enter a number :");
- int num1 = scanner.nextInt();
- if(num1 != 3) {
- flag = 1;
- System.out.println("Sorry, that was incorrect!");
- System.out.println("Better luck next time!");
- }
- else {
- System.out.println("Correct!");
- }
- int num69 = 0;
- if(num1 == 3) {
- System.out.println("\nPHASE 2"); //phase 2
- System.out.println("Enter a number :");
- int num2 = scanner.nextInt(); //phase 2
- if(num2 == 1 | (num2 >= 33 & num2 <= 100) ) {
- System.out.println("Correct!");
- num69 = 1;
- }
- else {
- flag = 1;
- System.out.println("Sorry, that was incorrect!");
- System.out.println("Better luck next time!");
- }
- }
- if(num69 == 1) {
- System.out.println("\nPHASE 3"); //phase 2
- System.out.println("Enter a number :");
- int num3 = scanner.nextInt();
- if(num3 > 1 && (num3 % 3 == 0 || num3 % 7 == 0)){
- System.out.println("Correct!");
- System.out.println("You have cracked the code!");
- flag = 2;
- }
- else {
- flag = 1;
- System.out.println("Sorry, that was incorrect!");
- System.out.println("Better luck next time!");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment