You are on page 1of 3

1.

Compute Simple Interest , Take Principle , ROI and Time as an Input from
Scanner or Command Line Argument.

CODE:-

import java.util.Scanner;

public class SimpleIntrest {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the principle amount -");
double principle = sc.nextDouble();
System.out.println("Enter the rate -");
float rate = sc.nextFloat();
System.out.println("Enter the time duration -");
float time = sc.nextFloat();
double SimpleInterest = (principle*rate*time)/100;
System.out.println("calculated simple interest is :
"+SimpleInterest);
sc.close();

}
}

OUTPUT:-
2.Compute Net Salary and Gross Salary , Take basic salary as an Input
e.g Enter the Basic Salary
Compute HRA - 50% of the Basic Salary
Compute TA - 30% of the Basic Salary
Compute MA - 25% of the Basic Salary
Compute PF - 10% of the Basic Salary
Gross Salary = Basic Salary + HRA + TA + MA
Tax = 10% Tax on Gross Salary
Net Salary = GrossSalary - Tax – PF , Print Net Salary
CODE:-
import java.util.Scanner;
public class Salary {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter basic salary :");
double Basic = sc.nextDouble();
double HRA = (0.5)*Basic;
double TA = (0.3)*Basic;
double MA = (0.25)*Basic;
double PF = (0.1)*Basic;
double grossSalary = Basic + HRA + TA + MA;
double tax = 0.1*grossSalary;
double netSalary = grossSalary - tax - PF;
System.out.println("Calculated HRA :"+HRA);
System.out.println("Calculated TA :"+TA);
System.out.println("Calculated MA :"+MA);
System.out.println("Calculated PF :"+PF);
System.out.println("Calculated Gross Salary
:"+grossSalary);
System.out.println("Calculated Tax :"+tax);
System.out.println("Calculated Net salary is:
"+netSalary);
sc.close();
}
}

OUTPUT:-

You might also like