Control Flow Statements - Branching
Control Flow Statements - Branching
Assignment #: 1
Sample Input1
Code :1
X : 24.50
Y : 67.00
Sample Output1
Sum : 91.50
Sample Input2
Code :4
Sample Output2
Sum : 0.00
Sample Input 1
Confidential v1.0
Sample Output 1
Sample Input 2
Sample Output 2
Sample Input 1
currentNumber : 17
Sample Output
currentNumber : 52
Sample Input 2
currentNumber : 26
Sample Output
currentNumber : 13
Confidential v1.0
Sample Input1
a : 3
b : 4
Sample Output1
teenSum : 7
Sample Input2
a : 10
b : 13
Sample Output2
teenSum : 19
Sample Input3
a : 13
b : 12
Sample Output3
teenSum : 19
5. Write a java program to find the mobile chosen is within the budget or
not. To find the budget mobiles is based on the below-mentioned
criteria,
a) If the cost of the mobile chosen is less than or equal to 15000 then
display it as "Mobile chosen is within the budget"
b) If the cost of the mobile chosen is greater than 15000 then display it
as "Mobile chosen is beyond the budget“
Sample Input 1:
Enter the cost of the mobile
12000
Sample Output 1:
Mobile chosen is within the budget
Confidential v1.0
Sample Input 2:
Enter the cost of the mobile
22000
Sample Output 2:
Mobile chosen is beyond the budget
6. Ana planned to choose a four digit lucky number for his car. Her lucky
numbers are 3,5 and 7. Help her to find the number, whose sum is divisible
by 3 or 5 or 7. Provide a valid car number, Fails to provide a valid input
then display that number is not a valid car number.
Sample Input 1:
Enter the car no:1234
Sample Output 1:
Lucky Number
Sample Input 2:
Sample Output 2:
Sample Input 3:
Sample Output 3:
Assume red for 'stop', green for 'go', and yellow for 'proceed with caution'.
Sample Input 1:
Confidential v1.0
Sample Output 1:
Go
Sample Input 2:
Sample Output 2:
Stop
Sample Input 3:
Sample Output 3:
Sample Input 4:
Sample Output 4:
prepare to go
8. Riya's teacher has asked her to prepare well for the lesson on seasons.
When her teacher tells a month, she needs to say the season corresponding
to that month. Write a program to solve the above task.
Confidential v1.0
Month should be in the range 1 to 12. If not the output should be
"Invalid month".
Sample Input 1:
Enter the month:11
Sample Output 1:
Season:Autumn
Sample Input 2:
Enter the month:13
Sample Output 2:
Invalid month
9,10 = Excellent
7,8 = Notable
6 = Good
5 = Approved
0-4 = Fail
>=10= Invalid
Sample Input1
Sample Output1
Excellent
Sample Input2
Sample Output2
Fail
Confidential v1.0