0% found this document useful (0 votes)
5 views1 page

Text

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Text

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Here are some practice questions for if-else statements in Java:

1. Write a Java program to check if a number is positive, negative, or zero using


if-else statements.
2. Create a Java program that asks for a user's age and then prints out whether
they are eligible to vote (18 or older) using an if-else statement.
3. Write a Java program that takes a grade (A, B, C, D, or F) as input and prints
out the corresponding GPA (4.0, 3.0, 2.0, 1.0, or 0.0) using if-else statements.
4. Develop a Java program that asks for a user's score on a test and then prints
out whether they passed (score 60 or higher) or failed using an if-else statement.
5. Create a Java program that takes a temperature in Celsius as input and prints
out whether it is hot (above 30), warm (between 20 and 30), or cold (below 20)
using if-else statements.
6. Write a Java program that asks for a user's height and weight and then prints
out whether they are underweight, normal weight, or overweight using if-else
statements.
7. Develop a Java program that takes a day of the week (Monday to Sunday) as input
and prints out whether it is a weekday or a weekend using if-else statements.
8. Create a Java program that asks for a user's score on a game and then prints out
whether they achieved a high score (above 1000), medium score (between 500 and
1000), or low score (below 500) using if-else statements.

Try to solve these questions on your own, and if you need help or want to check
your answers, feel free to ask!

You might also like