0% found this document useful (0 votes)
39 views2 pages

Conditional Questions-1

The document contains 5 questions about conditional statements in Java. The questions cover getting user input to check if a number is positive or negative, using an if statement to check a temperature, using a switch statement to print the day name from the week number, using a ternary operator to assign values to variables based on condition checks, and checking if a user input year is a leap year or not.

Uploaded by

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

Conditional Questions-1

The document contains 5 questions about conditional statements in Java. The questions cover getting user input to check if a number is positive or negative, using an if statement to check a temperature, using a switch statement to print the day name from the week number, using a ternary operator to assign values to variables based on condition checks, and checking if a user input year is a leap year or not.

Uploaded by

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

CONDITIONAL STATEMENTS QUESTIONS

Question 1 : Write a Java program to get a number from the user and print whether it is
positive or negative.

Question 2 : Finish the following code so that it prints You have a fever if your temperature
is above 100 and otherwise prints You don't have a fever.

public class Solution {


public static void main(String[] args) {
double temp = 103.5;
}
}

Question 3 : Write a Java program to input week number(1-7) and print day of week name
using switch case.

Question 4 : What will be the value of x & y in the following program:


public class Solution {
public static void main(String args[]) {
int a = 63, b = 36;
boolean x = (a < b ) ? true : false;
int y= (a > b ) ? a : b;
}
}

Question 5 : Write a Java program that takes a year from the user and print whether that
year is a leap year or not.

Hint:

You might also like