# Field Manual for Hackers

## Java Write a program to calculate gross salary.

Write a program to calculate gross salary.

•         DA=70% and HRA=10% if basic salary<15000.
•         DA=98% and HRA=500 if basic salary>=15000.
• NO DA HRA   if salary <10000

1. import java.util.Scanner;

class Test{

public static void main(String ar[])
{

Scanner sc=new Scanner(System.in);
double salary;
System.out.println("Enter Salary");
salary=sc.nextDouble();

if(salary<=10000){System.out.println("No DA and HRA. Your gross salary is "+salary);}
else if(salary>10000 && salary<=15000){
double hra,da,gsalary;
hra=500;
da=salary*98/100;
gsalary=salary+hra+da;
System.out.println("DA = "+da);
System.out.println("HRA = "+hra);
System.out.println("GROSS SALARY = "+gsalary);
}
else {
double hra,da,gsalary;
hra=salary*10/100;
da=salary*70/100;
gsalary=salary+hra+da;
System.out.println("DA = "+da);
System.out.println("HRA = "+hra);
System.out.println("GROSS SALARY = "+gsalary);
}

}
}

2. import java.util.Scanner;
class Salary
{
public static void main(String Args[])
{
double DA,HRA; //DA=daily alliance, HRA=home rent alliance
Scanner sc=new Scanner(System.in);
System.out.println("enter the salary");
double sal=sc.nextDouble();
if(sal<10000)
System.out.println("gross salary is"+sal);
else if(sal<15000)
{
DA=(0.7*sal);
HRA=(0.1*sal);
sal=(int)sal+DA+HRA;
System.out.println("gross salary is"+sal);
}
else
{
DA=(0.98*sal);
HRA=500;
sal=(int)sal+DA+HRA;
System.out.println("gross salary is"+sal);

}

}
}

3. import java.util.Scanner;
class GrossSalary
{
public static void main(String ar[])
{
double salary;
Scanner scan=new Scanner(System.in);
System.out.println("Enter the salery");
salary=scan.nextDouble();
if(salary<10000)
{
System.out.println(" There is no Daily Allowance & House Rent Allowance");
System.out.println(" The salery="+salary);

}
else if(salary<15000)
{
double DA,HRA,Total;
DA=salary*0.7;
HRA=salary*0.1;
Total=salary+DA+HRA;
System.out.println(" The Daily allowance="+DA);
System.out.println(" The House Rent Allowance="+HRA);
System.out.println(" The salery="+Total);
}
else
{
double DA,HRA,Total;
DA=salary*0.98;
HRA=500;
Total=salary+DA+HRA;
System.out.println(" The Daily allowance="+DA);
System.out.println(" The House Rent Allowance="+HRA);
System.out.println(" The salery="+Total);
}
}
}

4. import java.util.Scanner;

class Test{

public static void main(String ar[]){

double bs,da,hra,gs;
System.out.print("Enter basic salary: ");
Scanner obj=new Scanner(System.in);
bs=obj.nextDouble();
if(bs<10000)
{ da=0;
hra=0;
}
else if(bs<15000)
{ da=0.7*bs;
hra=0.1*bs;
}
else
{
da=0.98*bs;
hra=500;
}
gs=bs+da+hra;
System.out.println("The DA is:"+da);
System.out.println("The HRA is:"+hra);
System.out.println("The gross salary is:"+gs);

}
}

5. 2.

2. import java.util.Scanner;
class A
{
public static void main(String args[])
{
Scanner obj=new Scanner(System.in);
int bsalary;
int da,hra;
int q;
bsalary=obj.nextInt();
if(bsalary<15000)
{
da=.7*;
hra=.1;
bsalary=da*hra*bsalary;
}
elseif(bsalary>=15000)
{
da=.98;
hra=500;
bsalary=da*hra*bsalary;
}
elseif(bsalary<10000)
{
da=0;
hra=0;
}
int gsalary;
gsalary=da+hra+bsalary;
System.out.println("The DA is:"+da);
System.out.println("The DA is:"+hra);
System.out.println("The DA is:"+gsalary);
}
}

6. import java.util.Scanner;

class salary {
public static void main (String ar[])
{
Scanner sal = new Scanner(System.in);
double bsalary , DA , HRA ;
System.out.println("Enter the basic salary");
bsalary = sal.nextDouble();

if(bsalary >=10000 && bsalary < 15000)
{ DA = (bsalary*70)/100;
HRA = (bsalary*10)/100;
System.out.println(" DA = " +DA);
System.out.println("HRA = " +HRA);
}
else
if(bsalary >= 15000)
{
DA = (bsalary*98)/100;
HRA = 500;
System.out.println("DA = " +DA);
System.out.println("HRA = " +HRA);
}
else
if(bsalary < 10000)
System.out.println(" NO DA HRA ");

}
}

7. import java.util.*;
public class Salary
{
public static void main(String args[])
{
double salary,gross,DA,HRA;
System.out.println("enter salary");
Scanner sc=new Scanner(System.in);
salary=sc.nextDouble();
if(salary<15000)
{
DA=(70*salary)/100;
HRA=(10*salary)/100;
gross=salary+DA+HRA;
System.out.println("Salary will be "+gross);
}
if(salary>=15000)
{
DA=(98*salary/100);
HRA=500*salary;
gross=salary+DA+HRA;
System.out.println("Salary will be "+gross);
}
if(salary<10000)
{
System.out.println("No HRA,DA, so salary will be "+salary);
}
}
}

8. import java.util.Scanner;
class Salary{
public static void main(String ar[]){
Scanner obj=new Scanner(System.in);
double da,hra,gross;
int basic;

System.out.println("enter the value os basic pay");
basic=obj.nextInt();
if(basic<10000)

{da=0;
hra=0;
gross=basic+da+hra;

System.out.println("the gross salary is "+gross);
}
else if(basic<15000)
{
da=basic*70/100;
hra=basic*20/100;
gross=da+hra+basic;
System.out.println("the gross salary is"+gross);
}
else if(basic>=15000)
{
da=basic*98/100;
hra=500;
gross=basic+da+hra;
System.out.println("the gross salary is"+gross);
}
}

}

9. import java.util.Scanner;
class Grosssalary{
public static void main(String[] args){
int n;
double hra,da,gsalary;
Scanner scan=new Scanner(System.in);
n=scan.nextInt();

if(n<10000){
hra=0;
da=0;
gsalary=n+hra+da;
}

else if(n>10000&&n<=15000){
hra=n*0.10;
da=n*0.70;
gsalary=n+hra+da;
}

else if(n>15000){
hra=500.0;
da=n*0.98;
gsalary=n+hra+da;
}
}
}

10. import java.util.Scanner;

class Salary{

public static void main(String ar[]){
int sal;
double da,hra,gsal;

Scanner scan=new Scanner(System.in);
System.out.println("Enter the salary:");
sal=scan.nextInt();

if(sal<10000){
System.out.println("No DA HRA!");
}
else if(sal<15000){
da=sal*0.70;
hra=sal*0.10;
gsal=sal+da+hra;
System.out.println("Gross Salary is:"+gsal);
}
else{
da=sal*0.98;
hra=500;
gsal=sal+da+hra;
System.out.println("Gross salary is:"+gsal);
}
}
}

11. public class Gross1 {

public static void main(String ar[]){

double bs,da,hra,gs;
System.out.print("Enter basic salary: ");
Scanner obj=new Scanner(System.in);
bs=obj.nextDouble();
if(bs<10000)
{ da=0;
hra=0;
}
else if(bs<15000)
{ da=0.7*bs;
hra=0.1*bs;
}
else
{
da=0.98*bs;
hra=500;
}
gs=bs+da+hra;
System.out.println("The DA is:"+da);
System.out.println("The HRA is:"+hra);
System.out.println("The gross salary is:"+gs);

}
}

12. import java.util.*;

class Sal{

public static void main(String ar[]){
Scanner s=new Scanner(System.in);
int salary;
double da,hra,gross;

System.out.println("Enter the salary:");
salary=s.nextInt();

if(salary<10000){
System.out.println("No DA HRA!");
}
else if(salary<15000){
da=salary*0.70;
hra=salary*0.10;
gross=salary+da+hra;
System.out.println("Gross Salary is:"+gross);
}
else{
da=salary*0.98;
hra=500;
gross=salary+da+hra;
System.out.println("Gross salary is:"+gross);
}
}
}

13. package com.example.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class GrossSalary extends Activity {

int DA,HRA,Salary,Gs;
Button btgs;
EditText etgs;
TextView tvgs;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gross_salary);

btgs=findViewById(R.id.btgs);
etgs=findViewById(R.id.etgs);
tvgs=findViewById(R.id.tvgs);

btgs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Salary=Integer.parseInt(etgs.getText().toString());

if (Salary>10000&&Salary<15000) {
DA = Salary * 7 / 10;
HRA = Salary * 1 / 10;

Gs = Salary + DA + HRA;

tvgs.setText("Gross Salary=" + Gs);
}else if (Salary>=15000) {

DA = Salary * 98 / 100;
HRA = 500;

Gs = Salary + DA + HRA;

tvgs.setText("Gross Salary=" + Gs);
}else if (Salary<10000){

tvgs.setText("No DA Or HRA");

}

}
});
}
}