Branching Statements ( Break/Continue ).

PHOTO EMBED

Mon Apr 19 2021 05:31:32 GMT+0000 (Coordinated Universal Time)

Saved by @ahmedqgqgq #java

import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        for (int i = 0; i < 10; i++) {
            if (i == 4) {
                break;
            }
            System.out.println("i=" + i);
        }
    }
}
import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        for (int i = 0; i < 10; i++) {
            if (i == 4) {
                break;
            }
            System.out.println("i=" + i);
        }
        System.out.println("Ahmed abdelmoneim");
    }
}
import java.util.Scanner;
public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        for (int i = 0; i < 10; i++) {
            if (i == 4) {
                continue;
            }
            System.out.println("i=" + i);
        }
        System.out.println("Ahmed abdelmoneim");
    }
}
import java.util.Scanner;

public class Mohamed {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Test yourself:");
        System.out.println("what is '5+10/2*10=?':");
        float UserAnswer, TheCorrectAnswer = 55;
        boolean questionAnswer = false;
        for (int i = 1; i < 3; i++) {
            UserAnswer = input.nextFloat();
            if (UserAnswer == TheCorrectAnswer) {
                questionAnswer = true;
                break;
            } else if (UserAnswer != TheCorrectAnswer) {
                System.out.println("Chance #" + (i + 1) + " : ");
                continue;
            }
        }
        if (questionAnswer) {
            System.out.println("Correct Answer");
        } else {
            System.out.println("Wrong Answer");
        }
    }
}
content_copyCOPY