1. Write a program to input the basic salary of a person. He get 15% of the basic as HRA, 7% of the basic as DA and 2% of the basic as Travel allowance. The total salary is calculated by adding Basic + HRA + DA + TA. The  PF is 10% of the basic salary. Calculate and print the total salary of person.
import java.io.*;
class salary
{
    public static void main() throws IOException
    {
           BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter your salary");
        double basic_salary=Double.parseDouble(br.readLine());
        String name="abc";
        double HRA=(15*basic_salary)/100;
        double DA=(7*basic_salary)/100;
        double TA=(2*basic_salary)/100;
        double PF=(10*basic_salary)/100;
        double net_salary=basic_salary+HRA+DA+TA-PF;
        System.out.println("Net salary is="+net_salary);
    }
}

Enter your salary

10000 Net salary is=17700.0

2. Write a program to convert Hours , minutes and Seconds to Seconds.

import java.io.*;
class TIME
{
    public static void main()throws IOException
    {
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter hours");
        double hr=Double.parseDouble(br.readLine());
System.out.println("Enter minutes");
        double min=Double.parseDouble(br.readLine());
System.out.println("Enter seconds");
        double sec=Double.parseDouble(br.readLine());
        double mint=hr*60*60;
        double seco=min*60;
        double total_sec=mint+seco+sec;
System.out.println("Total seconds="+total_sec);
    }
}
Enter hours 2 Enter minutes 20 Enter seconds 2 Total seconds=8402.0

3. Write a program to take a number (between 1 to 12) and print the name of the month and number of days of the month .

import java.io.*;
class months
{
    public static void main()throws IOException
    {
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a Number");
intval=Integer.parseInt(br.readLine());
        switch(val)
        {
            case 1:
System.out.println("January");
System.out.println("31 days");
            break;
            case 2:
System.out.println("February");
System.out.println("28 days");
            break;
            case 3:
System.out.println("March");
System.out.println("31 days");
            break;
            case 4:
System.out.println("April");
System.out.println("30 days");
            break;
            case 5:
System.out.println("May");
System.out.println("31 days");
            break;
            case 6:
System.out.println("June");
System.out.println("30 days");
            break;
            case 7:
System.out.println("July");
System.out.println("31 days");
            break;
            case 8:
System.out.println("August");
System.out.println("31 days");
            break;
            case 9:
System.out.println("September");
System.out.println("30 days");
            break;
            case 10:
System.out.println("October");
System.out.println("31 days");
            break;
            case 11:
System.out.println("November");
System.out.println("30 days");
            break;
            case 12:
System.out.println("December");
System.out.println("31 days");
            break;
            default:
System.out.println("Wrong choice.Give a value between 1 and 12.");
        }
    }
}
Enter a Number 4
April
30 days

LEAVE A REPLY

Please enter your comment!
Please enter your name here