TABLE OF CONTENTS (HIDE)
1. Exercises on Flow Controls
1.1 Exercises on Conditional (Decision)
1.2 Exercises on Loop (Iteration)
1.3 Exercises on Nested-Loop
2. Exercises on Keyboard and File Input
3. Exercises on User Input and String Operations
4. Exercises on Array
5. Exercises on Command-line Arguments
6. Exercises on Method
7. More (Difficult) Exercises
8. Exercises on Number Theory
Java Programming Tutorial
Exercises on Java Basics
-------------------------------------------------
1. Exercises on Flow Controls
-------------------------------------------------
1.1 Exercises on Conditional (Decision)
Exercise CheckPassFail (if-else): Write a program called CheckPassFail which prints "PASS" if the int variable "mark" is more than or equal to 50; or prints "FAIL" otherwise.
Hints:
------------------------------------------------- public class CheckPassFail { // saved as "CheckPassFail.java"
-------------------------------------------------
public static void main(String[] args) {
-------------------------------------------------
int mark = 49; // set the value of mark here!
-------------------------------------------------
System.out.println("The mark is " + mark);
-------------------------------------------------
------------------------------------------------- if ( ...... ) {
-------------------------------------------------
System.out.println( ...... );
-------------------------------------------------
} else {
-------------------------------------------------
System.out.println( ...... );
-------------------------------------------------
}
-------------------------------------------------
}