Questions:

  1. Write a program to calculate tax, given the following conditions:
    1. If income is less than 150000 then no tax
    2. If taxable income is in the range 150001 to 300000 then charge 10% tax
    3. If taxable income is in the range 300001 to 500000 then charge 20% tax
    4. If taxable income is above 500001 then charge 30% tax
  2. Write a program to enter the marks of a student in 4 different subjects. Then display the grade of the student as per the following conditions:
    1. If the average mark is greater than or equal to 90 then grade is O
    2. If the average mark is greater than equal to 80 but less than 90 then grade is E
    3. If the average mark is greater than equal to 70 but less than 80 then grade is A
    4. If the average mark is greater than equal to 60 but less than 70 then grade is B
    5. If the average mark is greater than equal to 50 but less than 60 then grade is C
    6. If the average mark is less than 50 then grade is F
  3. Write a program to calculate the roots of a quadratic equation.
  4. Write a program to enter a number from 1 to 7 and display the corresponding day of the week using switch statement.
  5. Write a program to find out the factorial of any inputted number.
  6. Write a program to check whether an inputted number is prime or not.
  7. Write a program to check whether an inputted number is palindrome or not.
  8. Write a program to find out the binary equivalent of any inputted decimal number.
  9. Write a program to display all Armstrong numbers from 1 to 10000.
  10. Write a program to find out the largest between two numbers using a conditional operator.
  11. Write a program to find out the largest between three numbers using the conditional operator.
  12. Write a recursive program to find the sum of n natural numbers. [ n is user input ]
  13. Write a recursive program to find the GCD of two inputted numbers.

Answers:

import java.util.Scanner;

class IncomeTax
{
	public static double IncomeTaxCalc(double income)
	{
		double tax = 0;
		if(income <= 150000)
			tax = 0;
		else if (income <= 500000)
			tax = (150000 * 0.10) + ((income - 30000) * 0.20);
		else
			tax = (150000 * 0.10) + (200000 * 0.20) + ((income - 500000) * 0.30);
		
		return tax;
	}	
	
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		
		System.out.print("Enter your Income: ");
		double income = sc.nextDouble();
		
		System.out.println("Your Tax Ammount will be: " + IncomeTaxCalc(income));
	}
}