Java Practice Exercise – Selection Control Structures

Control Structures

Selection Structure
  • Check if given number is odd or even
  • Check for leap year
  • Divisibility by 5
  • Biggest / smallest of two numbers
  • Check if a given number is positive, negative or zero
  • Biggest / smallest of three numbers
  • Student grades
  • Check if given number is a single digit or not
  • Check if given number is a single, two, three or four digit number.
  • Check if given character is vowel or not
  • Check if given character is an arithmetic operator or not
  • Implicit checking
    • if(y!=0) // if(y)
    • If(y==0) // if(!y)
  • Ternary operator
    • Biggest / smallest of two numbers
    • Biggest / smallest of three numbers
  • Read a customer name, number of items purchased and price of item. If gross amount is greater than 500, a discount of 10 % is applicable. Find the net amount to be paid by the customer.
  • Consider the sales done by different sales persons in an organization and calculate the incentive amount for them based on the amount of sales.
Sales
Incentive
Greater than 50,000
10%
Between 30,000 and 50,000
8%
Between 10,000 and 30,000
5%
Otherwise
0
  • Calculate the income tax for a person based on different categories as given below. Find the amount to be paid as income tax under the above categories.
    • If income>=6,00,000 – it is 10% for above 8,00,000 and 5% for below 8,00,000
    • If income<6,00,000 and >=3,00,00 – it is 3% for above 4,00,000 and 2% for below 4,00,000
    • If income<3,00,000 – it is 1%