2a.self-Practice_Introduction to Java - Questions (1)
2a.self-Practice_Introduction to Java - Questions (1)
Practice No. : 2a
Date : 13.02.2025
Question
Question Detail Level
No.
Solution:
package self_practice;
import java.util.Scanner;
scanner.close();
}
Sometimes later becomes never. DO IT NOW!
1
SELF PRACTICE
SDE Readiness Training
}
2 Determine whether we are in trouble based on the smiling status Easy
of two monkeys, 'aSmile' and 'bSmile'. We are in trouble if both
monkeys are smiling or if neither of them is smiling. Return true
if we are in trouble
Sample Input: false false
Solution:
package self_practice;
import java.util.Scanner;
Solution:
package self_practice;
import java.util.Scanner;
4 We're hosting a party with tea and candy. The outcome of the Easy
party is encoded as follows: 0=bad, 1=good, or 2=great. A party
is considered good (1) if both tea and candy are at least 5. If
either tea or candy is at least double the amount of the other
one, the party is great (2). However, if either tea or candy is less
than 5, the party is always bad (0).
Sample Input: 6 8
Sample Output: 1
Sample Input: 3 8
Sample Output: 0
Sample Input: 20 6
Sample Output: 2
Solution:
package self_practice;
import java.util.Scanner;
Sometimes later becomes never. DO IT NOW!
3
SELF PRACTICE
SDE Readiness Training
Sample Input: 2 3
Sample Output: 5
Sample Input: 8 3
Sample Output: 8
Solution:
package self_practice;
import java.util.Scanner;
Solution:
package self_practice;
import java.util.Scanner;
Solution:
package self_practice;
import java.util.Scanner;
8 Write a Java program to calculate Net Salary. User must input Easy
Basic Salary and Output should be net salary calculated based on
the following allowances:
Allowances:
DA = 70% of Basic Salary
HRA = 7% of Basic Salary
MA = 2% of Basic Salary
TA = 4% of Basic Salary
Deduction:
PF = 12% of Basic Salary
Income/professional tax = User Input (e.g., 500)
Net Salary = Basic Salary + Allowances – Deduction
Solution:
package self_practice;
import java.util.Scanner;
Sometimes later becomes never. DO IT NOW!
7
SELF PRACTICE
SDE Readiness Training