import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        //System.out.println("Hello world!");

        // ---------------------------------------------------------------------
        
        //1. PROBLEM STATEMENT : ODD Number or Even Number ?
        
        // Scanner scn = new Scanner(System.in);
        // int n = scn.nextInt();

        // if(n%2==0){
        //     System.out.println(n+ " is Even Number.");
        // } else {
        //     System.out.println(n+ " is Odd Number.");
        // }

        // ---------------------------------------------------------------------

        //2. PROBLEM STATEMENT : DIVISIBLE BY GIVEN NUMBER OR NOT ?
            // Scanner scn = new Scanner(System.in);
                    
            //     int N = scn.nextInt();
            //     int D = scn.nextInt();
            // // int EO= scn.nextInt();

            // if(N%D==0){
            //     System.out.println(N + " is Divisble by " + D + ".");
            //     }

            // else if(N%D!=0){
            //     System.out.println(N + " is Not Divisble by " + D + ".");
            //     }

        // ---------------------------------------------------------------------
        
        //3. PROBLEM STATEMENT : Check whether given user input is positive, negative or ZERO ||

        // ---------------------------------------------------------------------

            // ASSIGNMENT

        // ---------------------------------------------------------------------

        // Q1. Check even/odd ?
            // Problem Description: Write a program to input an integer from user and print 1 if it is odd otherwise print 0.
            // Input Format : One line containing an integer N.
            // Output Format: Print either 1 or 0 as per the question.

            // Scanner scn = new Scanner(System.in);
            // int N = scn.nextInt();

            // if(N%2==0){
            //     System.out.println("0");
            // }else{
            //     System.out.println("1");
            //     }


        // ---------------------------------------------------------------------
        
        // Q2. Angles Of Valid Triangle?
        
        // Problem Description: You are given 3 integer angles(in degrees) A, B and C of a triangle. 
        // You have to tell whether the triangle is valid or not.
        // A triangle is valid if sum of its angles equals to 180.
        // Input Format: First line of the input contains an integer A.
        // Second line of the input contains an integer B.
        // Third line of the input contains an integer C.
        // Output Format: Print 1 if the triangle having given sides is valid, else print 0.

        // Scanner scn = new Scanner(System.in);
        // int A = scn.nextInt();
        // int B = scn.nextInt();
        // int C = scn.nextInt();
        // int D = 180;

        //     if(A+B+C == D){
        //     System.out.println("1");
        //     }else{
        //     System.out.println("0");
        //     }

        // ---------------------------------------------------------------------

        // Q3. Problem Description: Categories the number 
        // Write a program to input a number(A) from user and
        // print 1 if it is positive, -1 if it is negative, 0 if it's neither positive nor negative.
        // Input Format : One line containing an integer A.
        // Output Format One line each 0/1/-1 as per the question.

        // Scanner scn = new Scanner(System.in);
        // int A = scn.nextInt();

        // if(A>0){
        // System.out.println("1");
        // } else if(A<0){
        // System.out.println("-1");
        // } else {
        // System.out.println("0");
        // }


        // ---------------------------------------------------------------------

        // Q4. Problem Description: Divisible By 5? 
        // Given a Number N. If number is divisible by 5, print "Divisible by 5".
        // Otherwise print "Not divisible by 5".
        // Input Format: In single line, take N in int variable.
        // Output Format: Print statement in single line accordingly.
            
        // Scanner scn = new Scanner(System.in);
        // int N = scn.nextInt();

        // if(N%5==0){
        //     System.out.println("Divisible by 5");
        // }else{
        //     System.out.println("Not divisible by 5");
        // }

        // ---------------------------------------------------------------------

        // Q5. Problem Description: Relation of 18 with N
        // Given a Number N, according to situation of N print the output.
        // Situations of N are : if N is greater than 18, print "N is Greater than 18"
        // Otherwise if N is less than 18, print "N is smaller than 18"
        // Otherwise Print "N is equal to 18".
        // Note : Intention of this problem is to teach you use of else-if so try to solve it using else-if.
        
        // Scanner scn = new Scanner(System.in);
        // int A = 18;
        // int N = scn.nextInt();

        // if(N>A){
        // System.out.println("N is Greater than 18");
        // } else if(N<A){
        // System.out.println("N is smaller than 18");
        // } else {
        // System.out.println("N is equal to 18");
        // }

        // ---------------------------------------------------------------------

        // Q6. Problem Description: Situation Of Person
        
        // Given temperature of person, analyse the situation of person and give him advice.
        // Situations and advice related with temperature are :
        // 1. temp is in range of [85.0 to 91.0] then advice is "Serious Hypothermia".
        // 2. temp is in range of (91.0 to 95.0) then advice is "Mild Hypothermia".
        // 3. temp is in range of [95.0 to 98.0] then advice is "Normal Temperature".
        // 4. temp if in range of (98.0 to 100.0] then advice is "Mild Fever".
        // 5. temp if in range of (100.0 to 105.0] then advice is "High Fever".

        // Note :
        // 1. Range of temperature in human body is hypothetical.
        // 2. We have two type of bracket is there in Range [] and ()
        // 3. [] means inclusive and () means exclusive.
        // 4. Intention of this problem is to teach you multiple ifs, so try to solve it using multiple ifs

        // Problem Constraints: 85.0 <= temp <= 105.0
        // Input Format: In single line, given temp. as an input.
        // Output Format: According to situation of temp, print the advice.

        // Scanner scn = new Scanner(System.in);
        // double temp = scn.nextDouble();

        // if(temp>100.00 && temp<=105.00){
        //     System.out.println("High Fever");
        // }else if(temp>98.0 && temp<=100.0){
        //     System.out.println("Mild Fever");
        // }else if(temp>=95.0 && temp<=98.0){
        //     System.out.println("Normal Temperature");
        // }else if(temp>91.0 && temp<95.0){
        //     System.out.println("Mild Hypothermia");
        // }else if(temp>=85.0 && temp<=91.0){
        //     System.out.println("Serious Hypothermia");
        // }

         // ---------------------------------------------------------------------

        // Q7. Problem Description:  Max of two
            // Write a program to input two numbers(A & B) from user and print the maximum element among A & B in each line.
            // Input Format: First line is a single integer A. Second line is a single integer B.
            // Output Format: One line containing the greater integer A or B.

            // Scanner scn = new Scanner(System.in);
            // int A = scn.nextInt();
            // int B = scn.nextInt();

            // if(A>B){
            //     System.out.println(A);
            // }else{
            //     System.out.println(B);
            // }


        // ---------------------------------------------------------------------
        
        // Q8. If Else - 1 MCQ A
        // State TRUE or FALSE:
        // “Every IF statement must be followed by an ELSE statement.”

        // ANSWER - FALSE

        // ---------------------------------------------------------------------
        
        // Q9. If Else - 1 MCQ B
        // An IF statement in Java is also a ___ statement.
        // Boolean
        // Conditional  - CORRECT ANSWER
        // Iterative
        // Optional

        // ---------------------------------------------------------------------

        // Q10. If Else - 1 MCQ C
        // If the condition of an IF-statement is false, which is true below.
        // IF block is executed.
        // Else block is executed.       -     CORRECT ANSWER
        // Both IF and ELSE blocks are skipped.
        // Both IF and ELSE blocks are executed.
        
        // ---------------------------------------------------------------------

        // Q11. If Else - 1 MCQ D
        // What are the maximum lines of code that can be written inside a Java style IF, ELSE or IF-ELSE block?
        // 32
        // 64
        // 512
        // No Limit    -  CORRECT ANSWER

        // ---------------------------------------------------------------------

        // Q12. If Else - 1 MCQ H -- State TRUE or FALSE:
        
        // “An IF statement code must be defined in between two Braces.”
        // ANSWER - FALSE

        // Scanner scn = new Scanner(System.in);
        // int A = 10;

        // if(A!=10)
        // System.out.println("False");
        
        // ( NOTE: THE ABOVE CODE WILL NOT THROW ANY ERROR, EVEN THOUGH IT MAY NOT PRINT ANYTHING, DESPITE THE IF CONDITION, IT IS 
        // NOT REALLY LOOKING FOR EXECUTING ANY FURTHER, FOR EXECUTING ANY CONDITION THAT EITHER SATISFY OR NOT.)

        // ---------------------------------------------------------------------

        // Q13. If Else - 1 MCQ J 
        // What is the output of the Java code snippet?

        // int k=20;
        // if(k)
        // {
        //  System.out.println("YES");
        // }
        // else
        // {
        //  System.out.println("NO");
        // }

        // 1. YES
        // 2. NO
        // 3. Compilation Error     - CORRECT ANSWER
        // 4. No output
        
        // ---------------------------------------------------------------------

        // Q14. If Else - 1 MCQ K
        // What is the output of the given Java program with IF statement?
        // if(1) {
        //   System.out.println("OK");
        // }

        // OK
        // No output
        // Compilation Error    - CORRECT ANSWER
        // None of the above
        
        // ---------------------------------------------------------------------

        // Q15. If Else - 1 MCQ L
        // What is the output of the given below program?

        // public class Main {
        // public static void main(String[] args) {
        // if(a<b)
        // System.out.println("Hi");
        // else
        // System.out.println("Hello");
        
        // Hi
        // Hello
        // Compiled Successfully, No output
        // Compile-time Error          -  CORRECT ANSWER

        // ---------------------------------------------------------------------

        // Q16. If Else - 1 MCQ M
        // What is the output of the Java program?

        // String name="dino";
        // if(name == "dino")
        // System.out.print("DINO ");
        // System.out.println("GOOD");

        // 1. DINO
        // 2. GOOD
        // 3. DINO GOOD          - CORRECT ANSWER
        // 4. Compilation Error


        // -----> ADDITIONAL PROBLEMS 
        
        // ---------------------------------------------------------------------

        // Q1. Is Divisible?
        
        // Problem Description
        // Given two Numbers N and X. If N is divisible by X print "Yes" otherwise print "No"
        // Input Format: First value denoting N. Second value denoting X.
        // Output Format: Print Yes or No

        // Scanner scn = new Scanner(System.in);
        // int N = scn.nextInt();
        // int X = scn.nextInt();

        // if(N%X==0){
        //     System.out.println("Yes");
        // }else{
        //     System.out.println("No");
        // }


        // ---------------------------------------------------------------------

        // Q2. Scored Century?
        // Problem Description
        // Given runs scored by a batsman, find if he has scored a century or not.
        // If he has scored a century print "Century!!!" otherwise print "Better luck next time!".

        // Input Format: Single value denoting runs.
        // Output Format: Print Century!!! or Better luck next time! according to runs given.

        // Scanner scn = new Scanner(System.in);
        // int Runs = scn.nextInt();

        // if(Runs>=100){
        //     System.out.println("Century!!!");
        // }else{
        //     System.out.println("Better luck next time!");
        // }

        // ---------------------------------------------------------------------

        // Q3. Problem Description : Min of two? 
        
        // Write a program to input two numbers(A & B) from user and print the minimum element among A & B in each line.

        // Input Format: First line is a single integer A. Second line is a single integer B.
        // Output Format: One line containing an integer as per the question.

        // Scanner scn = new Scanner(System.in);
        // int A = scn.nextInt();
        // int B = scn.nextInt();

        // if(A>B){
        //     System.out.println(B);
        // }else{
        //     System.out.println(A);
        // }
                
        // ---------------------------------------------------------------------

        // Q4. Problem Description: Profit Or Loss ? 
        
        // You are given the Cost Price C and Selling Price S of a Product. You have to tell whether there is a Profit or Loss. 
        // Also, calculate total profit or loss.
        // NOTE: It is guaranteed that Cost Price and Selling Price are not equal.
        // Input Format: First line of the input contains a single integer C.
        // Second line of the input contains a single integer S.
        // Output Format: Print two integers in separate lines.
        // First integer denotes whether there is a profit or loss. If there is a profit, print 1, else print -1.
        // Second integer is a non-negative integer denoting the absolute value of total profit or loss.

        // Scanner scn = new Scanner(System.in);
        // int CP = scn.nextInt();
        // int SP = scn.nextInt();
        
        // if(CP<SP){
        //     System.out.println("1");
        //     System.out.println(SP-CP);
        // }else{
        //     System.out.println("-1");
        //     System.out.println(CP-SP);
        // }

        // ---------------------------------------------------------------------
        // Q5. Calculate Attendance ? 

        // Problem Description
        // Exams are near and Rahul is worried whether he will be allowed to take the exams or not. 
        // A student is not allowed to take the exams if his/her attendance is less than 75%. 
        // But Rahul is a little weak in math, so he wants your help to tell him whether he will be able to give exams or not.
        // You are given the total number of classes held (T) and number of classes attended by Rahul (N), print YES or NO.
        // Input Format: First line is T means total classes. Second line is N means classes attended by Rahul.
        // Output Format: Print YES if Rahul’s attendance is >= 75% , otherwise print NO

        // Scanner scn = new Scanner(System.in);
        // int T = scn.nextInt();
        // int N = scn.nextInt();
        // int att= 75;
    
        // int R = (N*100/T);
        
        // if (R>=att){
        //     System.out.println("YES");
        // }else{
        //     System.out.println("No");
        // }

        // ---------------------------------------------------------------------

          // Q6. Problem Description: Class Performance 2 ? 
              
            // You have been given a dataset for marks of 2 subjects, scored by students of classes ClassA and ClassB.
            // You now want to compare the performances of class A and class B by finding out the average performance 
            // of the classes. Write a program to find if class A performed better. Print True is Class A is strictly
            // better else return False.
            // Input Format:
            // There are 4 lines in the input. The first and second lines are marks of subjects for Class A.
            // The third and fourth lines are marks of subjects for Class B.
            // Output Format:
            // Print True if class A is strictly better else False.

            // Scanner scn = new Scanner(System.in);
            // int ClassA1 = scn.nextInt();
            // int ClassA2 = scn.nextInt();
            // int ClassB1 = scn.nextInt();
            // int ClassB2 = scn.nextInt();

            // int ClassA = (ClassA1 + ClassA2);
            // int ClassB = (ClassB1 + ClassB2);

            // if (ClassA > ClassB){
            //     System.out.println("True");
            // }else{
            //     System.out.println("False");
            // }
        
        // ---------------------------------------------------------------------

        // Q7. Problem Description: Divisible by 2 numbers
        // Take an integer A as input. You have to tell whether A is divible by both 5 and 11 or not.
        // Input Format: The input contains a single integer A.
        // Output Format: Print 1 if A is divisible by both 5 and 11, else print 0.

        // Scanner scn = new Scanner(System.in);
        // int A = scn.nextInt();

        // if (A%5==0 && A%11==0){
        //     System.out.println("1");
        // }else{
        //     System.out.println("0");
        // }
    
        // ---------------------------------------------------------------------
        // Q8. Problem Description: Roller Coaster Ride
        // Write a program that takes the age of the user as input and tells them if they're old enough 
        // to ride a roller coaster. The minimum age to ride the roller coaster in this question is 13.
        // Input Format : There is only 1 single line in the input, which is the age of the user.
        // Output Format:
        // Print the following if user can ride the roller coaster: You can ride the roller coaster!
        // Print the following if user can't ride the roller coaster: You can't ride the roller coaster.

            // Scanner scn = new Scanner(System.in);
            // int age = scn.nextInt();

            // if(age>=13){
            //     System.out.println("You can ride the roller coaster!");
            // }else{
            //     System.out.println("You can't ride the roller coaster.");
            // }

        // ---------------------------------------------------------------------
        // Q9. Problem Description: Situation Of Number
        // Check whether a given number is positive-odd, positive-even, negative-odd OR negative-even.
        // Write a code to figure out the Situation.
        // Take a number N from user and print the Situation Of Number.
        // if positive-odd : print -> "Number is Positive and Odd"
        // if positive-even : print -> "Number is Positive and Even"
        // if negative-odd : print -> "Number is Negative and Odd"
        // if negative-even : print -> "Number is Negative and Even"
        // Input Format: Take a number N from user.
        // Output Format: Print the Situation Of Number according to condition. 

        // Scanner scn = new Scanner(System.in);
        // int N = scn.nextInt();

        // if(N%2==0 && N>=0){
        //     System.out.println("Number is Positive and Even");
        // }if (N%2==0 && N<0){
        //     System.out.println("Number is Negative and Even");
        // }if(N%2!=0 && N>=0){
        //     System.out.println("Number is Positive and Odd");
        // }if(N%2!=0 && N<0){
        //     System.out.println("Number is Negative and Odd");
        // }
        
        // ---------------------------------------------------------------------
        // Q10. Problem Description: Employee Bonus
        // A company decided to give bonus of 5% to employee if his/her year of service is more than 5 years. 
        // Ask user for their name and year of service and print whether they should recieve bonus or not.
        // Input Format:  First line contains name of the employee. Second line contains the years of service
        // Output Format: Print whether or not the employee will recieve bonus.
        // Example Output
        // Output 1: Yes Mukesh will recieve bonus.
        // Output 2: No Shalini will not recieve bonus.

        // Scanner scn = new Scanner(System.in);
        // String name = scn.nextLine();
        // int serv = scn.nextInt();
        
        // if(serv>5){
        //     System.out.println("Yes " + name + " will recieve bonus.");
        // }else{
        //     System.out.println("No " + name + " will not recieve bonus.");
        // }

        // ---------------------------------------------------------------------
        // Q11. Problem Description: Rockstar?
        // Given a Number N, print the answer according to the following rules-
        // If N is divisible by 3 print Rock
        // If N is divisible by 5 print star
        // If N is divisible by both 3 and 5 print Rockstar
        // Note : You are allowed to use only if condition. Don’t use else or else-if condition. This constraint is provided for learning purposes.
        // Input Format: The value of N.
        // Output Format: Print the appropriate message according to the value of N.

        // Scanner scn = new Scanner(System.in);
        // int N = scn.nextInt();

        // if(N%5==0 && N%3!=0){
        //     System.out.println("Rock");
        // }
        //     if(N%3==0 && N%5!=0){
        //     System.out.println("star");
        // }
        //   if(N%3==0 && N%5==0){
        //     System.out.println("Rockstar");
        // }
        
         // ---------------------------------------------------------------------

            // Q12. If Else - 1 MCQ N
            // boolean x, y, z;
            // x = y = z = true;
            // if(!x || (!y && !z))
            // System.out.println("WHY");
            // else
            // System.out.println("WHAT");
            
            // Select Answer from Below:
            // WHY
            // WHAT             - CORRECT ANSWER 
            // Compilation Error
            // No output
            // if(!x || (!y && !z)) - CONVERTED BELOW.
            // !x = true to false || (!y = true to false && !z = true to false)
            // -- false || (false) - Which is false, hence, if block will not be executed and else will be executed
                
        // ---------------------------------------------------------------------
            // Q13. If Else - 1 MCQ O
            // float a = 7.3f;
            // if(a == 7.3)
            // System.out.print("Hi");
            // else
            // System.out.print("Know Program");
            
            // Select Answer from Below:
            // Hi
            // Know Program      -  CORRECT ANSWER.
            // Compilation Error
            // Compiled Successfully, No Output.

        // ---------------------------------------------------------------------
            // Q14. If Else - 1 MCQ P
            // The condition of an IF statement evaluates to boolean only if the expression contains?
            // Logical Operators
            // Relational Operators
            // Boolean Operators
            // All of the above         -  CORRECT ANSWER

        // ---------------------------------------------------------------------
            // Q15. If Else - 1 MCQ Q
            // Choose the correct syntax of Java IF statement below.
            // if(condition) //statement
            // if(condition){ //statement }
            // if(condition){ //statement1 //statement2 }
            // All of the above     -  CORRECT ANSWER

              // if(false)
              // System.out.println("Correct");
                
        // ---------------------------------------------------------------------
            // Q16. If Else - 1 MCQ R
            // What is the output of the Java code snippet?
            // int a=5, b=6;
            // if(a++ == --b){
            // System.out.println("5=5");
            // }
            // else{
            // System.out.println("NONE");
            // }
            // CHOOSE ANSWER FROM BELOW:
            // NONE
            // 5=5              = CORRECT ANSWER 
            // Compilation Error
            // None of the above
            // Note: (a++ change value from 5 to 6 after the line execution, 
            // but --b will execute the b value before the execution completion of line).
            // Therefore, a will remain a = 5 and b will change to b=5 from b=6 ||

            
        // ---------------------------------------------------------------------
            // Q17. If Else - 1 MCQ S
            // What will be the output of the following JAVA snippet?

            // int x = 10;
            // if(x >= 10){
            // System.out.print(“YES ”);
            // }
            // else if (x > 5)
            // {System.out.print(“NO ”);
            // }
            // YES         -     CORRECT ANSWER - Else if will not be executed by the if condition is already met.
            // NO
            // YES NO
            // NO YES
                
    // ---------------------------------------------------------------------

        

        

































        
        
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: