Solution:: Exercise Sheet: Java If Statement
Solution:: Exercise Sheet: Java If Statement
Ex 2. Write a Java program that reads two values from user and check if either of them is
divisible by the other, then print the result on screen.
Examples of running:
If the user entered 15 and 5, the output should be: Yes, 15 is divisible by 5.
If the user entered 3 and 12, the output should be: Yes, 12 is divisible by 3.
If the user entered 7 and 13, the output should be: None is divisible.
Solution:
Ex 3. Write a Java program that reads 2 integers from the user and prints the greater value.
Solution:
Ex 4. Write the Java program that asks the user to enter the car speed, the program reads the
speed and check:
if the Speed is from 0 to 60, the program will print: “No ticket”
if the Speed is from 61 to 80, the program will print: “Small ticket”
if the Speed is more than 80, the program will print: “Big ticket”
Solution: