Program 1: Write a program which does the following: Takes 2 int data type inputs from the user, say in num1 and num2. And print true if any one of the numbers is equal to 100 or their sum is equal to 99. Else print false. But there is a restriction: This logic for point# 2 above should be done inside the println() statement. So everything should be done inside this: System.out. println(... write logic here...); //hint: use logical operators Program 2: Write a program which does the following: Takes 2 int data type inputs from the user, say in num1 and num2. And print true if both the numbers are between 11 and 99 (inclusive), or if both the numbers are between 99 and 199 (inclusive). Else print false. But there is a restriction: This logic for point# 2 above should be done inside the println() statement. So everything should be done inside this: System.out. println(... write logic here...); //hint: use logical operators
Write a program which does the following:
-
Takes 2 int data type inputs from the user, say in num1 and num2.
-
And print true if any one of the numbers is equal to 100 or their sum is equal to 99. Else
print false.
-
But there is a restriction:
This logic for point# 2 above should be done inside the println() statement. So everything should be done inside this:
System.out. println(... write logic here...); //hint: use logical operators
Program 2:
Write a program which does the following:
-
Takes 2 int data type inputs from the user, say in num1 and num2.
-
And print true if both the numbers are between 11 and 99 (inclusive), or if both the numbers
are between 99 and 199 (inclusive). Else print false.
-
But there is a restriction:
This logic for point# 2 above should be done inside the println() statement. So everything should be done inside this:
System.out. println(... write logic here...); //hint: use logical operators
Program 3:
1. Create a String constant ‘SPACE’, which holds a space ( “ “ ).
final String SPACE = " "; /*‘final’ keyword creates a constant in Java. Once a ‘final’ variable is initialized, it values cannot be changed*/
2. Get the name of your ( or a fictional ) pet and save it to a String variable.
3. Get the age of your (or a fictional ) pet and save it to an int variable.
4. Print out the name and age of your pet, use your constant in the println wherever space character is needed.
Sample output:
Enter name : yoyo
Enter age: 3
My pet's name: Yoyo
My pet's age : 3
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images