0% found this document useful (0 votes)
58 views2 pages

Import Class Public Static Void New Double Int While: "Enter Salary: "

The document contains code for a Java program that calculates welfare contributions from employee salaries. It prompts the user to enter salaries and categorizes them based on thresholds. It then calculates the total contributions and numbers of employees in each category. The program outputs the total contributions collected, contributions from each category, and number of employees in each category.

Uploaded by

Sharvin Vanan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views2 pages

Import Class Public Static Void New Double Int While: "Enter Salary: "

The document contains code for a Java program that calculates welfare contributions from employee salaries. It prompts the user to enter salaries and categorizes them based on thresholds. It then calculates the total contributions and numbers of employees in each category. The program outputs the total contributions collected, contributions from each category, and number of employees in each category.

Uploaded by

Sharvin Vanan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import java.util.

Scanner;

class Welfare{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
double salary, category1, category2, category3, totalcollection=0, totalcategory1=0,
totalcategory2=0, totalcategory3=0;
int staff=0, numcategory1=0, numcategory2=0, numcategory3=0;

while(staff<20){
System.out.print("Enter Salary: ");
salary = sc.nextDouble();
if(salary<1000){
category1 = salary*0.02;
numcategory1 = numcategory1 + 1;
totalcategory1 = totalcategory1 + category1;
totalcollection = totalcollection + category1;
}
else if(salary<=2500){
category2 = salary*0.03;
numcategory2 = numcategory2 + 1;
totalcategory2 = totalcategory2 + category2;
totalcollection = totalcollection + category2;
}
else {
category3 = salary*0.05;
numcategory3 = numcategory3 + 1;
totalcategory3 = totalcategory3 + category3;
totalcollection = totalcollection + category3;
}
staff = staff + 1;
}

System.out.println("Total collection for the month: "+totalcollection);


System.out.println("Total collection by gross salary less than RM1000.00: "+totalcategory1);
System.out.println("Total collection by gross salary between RM1000.00 - RM2500.00:
"+totalcategory2);
System.out.println("Total collection by gross salary more than RM 2500.00:
"+totalcategory3);
System.out.println("The number of staff by gross salary less than RM 1000.00:
"+numcategory1);
System.out.println("The number of staff by gross salary between RM 1000.00 - RM 2500.00:
"+numcategory2);
System.out.print("The number of staff by gross salary more than RM 2500.00: "+numcategory3);
}}

You might also like