0% found this document useful (0 votes)
2 views

JAVA - 3

The document contains a series of programming tasks that involve comparing numbers, calculating sums, and determining properties of geometric shapes. Each task includes descriptions, input formats, output requirements, and sample inputs with expected outputs. The tasks cover various operations such as comparisons, arithmetic calculations, and conditions based on user-provided values.

Uploaded by

masaidsa1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

JAVA - 3

The document contains a series of programming tasks that involve comparing numbers, calculating sums, and determining properties of geometric shapes. Each task includes descriptions, input formats, output requirements, and sample inputs with expected outputs. The tasks cover various operations such as comparisons, arithmetic calculations, and conditions based on user-provided values.

Uploaded by

masaidsa1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1.

Update & Compare Ended

Description

● You are given two numbers, stored in variables with the namesnum1andnum2

Print the output of the following operation


num1 > num2, this prints true if num1 is greater than num2, else it prints
false

After this operation is performed, another number, stored in a variable with namenum3is added to num1.
After this, print the result of the following operation again
num1 > num2, this prints true if num1 is greater than num2, else it prints
false

Input

● The first and the only line of input contains the values stored in num1, num2 and num3

Output

Print the result of the operations given in the problem statement

Sample Input 1
4 8 5

Sample Output 1
false
true

Hint

In the sample test case, the value stored innum1 = 4, while the value stored innum2 = 8. The result of

the operation

num1 > num2, such that 4 is not greater than 8, so the output is false
After this step, the value stored innum3 = 5, is added to num1, so the value stored in num1 becomesnum1

= num1 + num3 = 4 + 5 = 9

Therefore, the result of the operation

num1 > num2, such that 9 is greater than 8, is true, so the output is true the second
time

2. Compare two Numbers Ended


Description

● You are given two numbers stored in two variables, with the name,num1andnum2

Print the result of the following operations


1. num1 > num2 -> this operation prints true, if num1 is greater than num2,
otherwise it prints false
2. num1 < num2 -> this operations prints true, if num1 is smaller than num2,
otherwise it prints false
3. num1 == num2 -> this operation print true, if num1 is equal to num2,
otherwise it prints false

● You have to print the result of three operations in the order as shown above

Input

● The first and the only line of input contains the values stored innum1andnum2

Output

Print the result of three operations, one by one, on a new line

Sample Input 1
4 16

Sample Output 1
false
true
false

Hint
In the sample test case, the value stored innum1 = 4and value stored innum2 = 16

In the first operationnum1 > num2, 4 is not greater than 16, so we get the output asfalse

In the second operationnum1 < num24 is lesser than 16, so we get the output astrue

In the third operationnum1 == num2, num1 is not equal to num2, so we get the output asfalse

3.Sum & Compare Ended


Description

You are given five numbers, stored in the variables with the following name
one, two, three, four, five

● You have to declare another variablesum1, such thatsum1 = one + two + three

● Also, you have to declare another variablesum2, such thatsum2 = four + five

Finally, you have to print the output of the following operation


sum1 > sum2 (This operation prints true, if sum1 is greater than sum2, else
it prints false)

Input

The first and the only line of input contains the values stored inone, two, three, four, five

Output

Print the result of the operation, after finding the values ofsum1andsum2, as explained in the problem

statement

Sample Input 1
1 2 3 4 5

Sample Output 1
false
Hint

In the sample test case, the values stored in the variables isone = 1, two = 2, three = 3, four =

4, five = 5

Therefore, the value ofsum1becomessum1 = one + two + three = 1 + 2 + 3 = 6

Similarly, the value ofsum2becomessum2 = four + five = 4 + 5 = 9

Now, the result of the operationsum1 > sum2will be false, assum1 = 4is not greater thansum2 = 5.

Hence, the output false

4.Compare Seven Numbers Ended


Description

You are given seven numbers, stored in the variable with the following names
a,b,c,d,e,f,g

● You have to declare two variables,sum1andsum2, such thatsum1 = (a + b) * candsum2 =

(d + e + f + g)

Print the output of the following operation


sum1 > sum2

Input

The first and the only line of input contains the seven numbers stored in the variable with the

namesa,b,c,d,e,f,g

Output

● Print the output of the operation, given in the problem statement

Sample Input 1
1 2 3 4 5 6 7
Sample Output 1
false

Hint

In the sample test case, the value stored in the variables is as follows

a = 1,b = 2,c = 3,d = 4,e = 5,f = 6,g = 7

The value of sum1, as explained in the problem statement will be,sum1 = (a + b) * c = (1 + 2) * 3

= (3) * 3 = 9

Similarly, the value of sum2, as explained in the problem statement will besum2 = (d + e + f + g) =

(4 + 5 + 6 + 7) = 22

The operationsum1 > sum2will print false, as the value of sum2 is greater than sum1, hence the output

false

5. Area and Perimeter Ended


Description

You are given the sides of the rectangle 1: L1 and B1 and sides of the rectangle 2 : L2 and B2.

You need print if area of rectangle 1 is greater than rectangle 2.

You need print if perimeter of rectangle 1 is greater than rectangle 2.

Input

The first line of each test case contains two space-separated integers L1, B1, L2, B2 , the length and

breadth of the rectangle1 andthe length and breadth of the rectangle2.

Constraints

1 <= L1, B1, L2, B2 <= 100

Output
Print(Area of rectangle 1 > Area of rectangle 2)

Print(Perimeter of rectangle 1 >Perimeter of rectangle 2)

Sample Input 1
1 2 2 3

Sample Output 1
false
false

6.Cube and Square Ended


Description

You are given two numbers n and m, you need to check if cube of n is greater than square of m.

Input

First line contains two space separated integers n and m.

Output

Print true if cube of n is greater than square of m, or else print false.

Sample Input 1
2 3

Sample Output 1
false

Hint

In the given sample test case n = 2 and m = 3 , so cube of n is 2*2*2 =8 and square of m is 3*3 = 9

Here cube of n is lessthan square of m.

Therefore Output is false

7.Divisible by 4 Ended
Description

You are given a number, stored in the variable with the nameN

PrintYes, if the number is divisible by 4, else printNo

Note : A number is divisible by 4, if the result of the following expression number


% 4 == 0

Input

First and only line contains one positive integer

N < 100000

Output

Output "Yes" and "No" depending on N.

Sample Input 1
12

Sample Output 1
Yes

8.Easy Wood Cutter Ended


Description

You are given a number, stored in a variable with the nameN. Check if the the number is divisible by 3 or

not

If its possible, print "Yes"

Else print "No"

Hint : A number can be divided into 3 parts, if the number is completely divisible
by 3, that is, the answer of the operation number % 3 is zero
Input

Input Format :

First line contains length of wood : N

Constraints :

N < 1000

Output

Print Yes/No based on the length

Sample Input 1
6

Sample Output 1
Yes

9. The Ashes! (But One day) Ended


Description

You are given two numbers, stored in variables with the following names

Australia, England

If the following expression is true

Australia > England, print "Australia"

else if the following expression is true

Australia < England, print "England"


else if the following expression is true

Australia == England, print "Tie"

Input

Input Format :

First and the only line contains 2 space separated integers denoting scores of Australia and England

respectively.

Constraints :

Both score <450

Output

Output one string(either Australia or England) which is the name of Winning team

Sample Input 1
46 67

Sample Output 1
England

10.Masai Even or Odd Ended


Description

You are given a number, stored in the variable with the nameN

If the number is even, printEven, else printOdd

If the number is divisible by 2, the number is consideredEven, else the number is consideredOdd

Input
Input Format

There is just one positive integer in input

Constraints

integer > 1

Output

Output Format

Print "Even" or "Odd" depending on the value.

Sample Input 1
5

Sample Output 1
Odd

11. Apply Brakes Ended


Description

You are given two numbers stored in the variable with the names

distance, time

Find the value of speed, such that,

speed = distance/time

If the following expression is true

speed > 40, print "Apply Brake"

else
print "Keep Going"

Print the statements, without quotes

Input

Input Format

First line contains 2 space separated integers where the first integer represents the distance travelled by

car and second represents time taken to cover that distance.

Constraints

Distance < 1000

time taken < 5

Output

Output a string depending on the speed of the car

Sample Input 1
100 2

Sample Output 1
Apply Brake

12. Enough Fuel Consumption Ended


Description

You are given two numbers, stored in the variable with the following names

fuel, distance

Find the value of required, such that

required = fuel*distance
If the value ofrequiredis greater than 50, printEnough, else printGo On

Input

Input Format

The first and the only line of input contains two values, stored in variablesfuel, distance

Constraints

Both numbers < 1000

Output

Output the correct statement based on the conditions mentioned in the problem statement.

Sample Input 1
1 46

Sample Output 1
Go On

Hint

In the sample test case, the value stored infuel = 1, and the value stored indistance = 46

Therefore, the value ofrequired = fuel * distance = 1 * 46 = 46, which is less than 50, hence

the outputGo On

You might also like