Вы находитесь на странице: 1из 9

JOHN RHENZ H.

JAPSAY
BIT- COMPUTER TECHNOLOGY
4A-G1

package javaproject1;

import java.text.*;

public class Taxes {


double incomeTax; double netPay;
NumberFormat formatter = new DecimalFormat("#0.00");
void Married(float grossPay, double deducted){
double adjustedGrosspay, tax;
adjustedGrosspay = grossPay - deducted;
if(adjustedGrosspay >= 0 && adjustedGrosspay <= 100){
tax = adjustedGrosspay - 50;
incomeTax = tax * .1;
}
else if(adjustedGrosspay >= 101 && adjustedGrosspay <= 300){
tax = adjustedGrosspay - 150;
incomeTax = tax * .2;
incomeTax += 20;
}
else if(adjustedGrosspay >= 301 && adjustedGrosspay <= 600){
tax = adjustedGrosspay - 350;
incomeTax = tax * .3;
incomeTax += 60;
}
else{
tax = adjustedGrosspay - 650;
incomeTax = tax * .5;

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
incomeTax += 180;
}
System.out.println("Computed Income Tax
:-P"+formatter.format(incomeTax));
}
void Single(float grossPay, double deducted){
double adjustedGrosspay, tax;
adjustedGrosspay = grossPay - deducted;
if(adjustedGrosspay >= 0 && adjustedGrosspay <= 100){
tax = adjustedGrosspay - 50;
incomeTax = tax * .1;
}
else if(adjustedGrosspay >= 101 && adjustedGrosspay <= 300){
tax = adjustedGrosspay - 150;
incomeTax = tax * .1;
incomeTax += 20;
}
else if(adjustedGrosspay >= 301 && adjustedGrosspay <= 600){
tax = adjustedGrosspay - 350;
incomeTax = tax * .15;
incomeTax += 60;
}
else{
tax = adjustedGrosspay - 650;
incomeTax = tax * .25;
incomeTax += 180;
}
System.out.println("Computed Income Tax
:-P"+formatter.format(incomeTax));

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
}
void Netpay(float grossPay){
netPay = grossPay - incomeTax;
System.out.println("Computed Net Pay
P"+formatter.format(netPay));

}
}

package javaproject1;
import java.io.*;
public class JavaProject1 {

public static void main(String[] args)throws IOException {


BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));
Calculate employee = new Calculate();
Arrays arrays = new Arrays();
int x = 0; int ctr = 0;
x++; ctr++;
while(x != 0){
employee.InputEmployeeNumber();
employee.InputEmployeeData();
employee.InputMaritalStatus();
employee.InputDeductions();
employee.GrossPay();
employee.ComputedPay();

System.out.print("\nDo you wish to do another(Y/N)? ");

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
String choice = input.readLine();
if(ctr < 20){
if(choice.equalsIgnoreCase("y")){
System.out.println("");
x++;
}
else if(choice.equalsIgnoreCase("n")){
System.out.println("");
employee.Arrays();
x = 0;
}
}
}
}
}

==================================================
==============================

package javaproject1;
import java.io.*;
import java.text.*;
public class Calculate {
public int regHours; public int overHours;
public float hourPayRate;
public float grossPay; int deductions; String status; double incomeTax, deducted;
int ctr = 0;

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
String empnum[] = new String[20];
float grosspay[] = new float[20];
double incometax[] = new double[20];
double netpay[]= new double[20];
String empNum;
void GrossPay(){

regHours *= hourPayRate;
hourPayRate *= 1.5;
overHours *= hourPayRate;
grossPay = regHours + overHours;

void InputEmployeeData()throws IOException{


BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));

System.out.print("Enter Regular Hours Worked

: ");

regHours = Integer.parseInt(input.readLine());
System.out.print("Enter Overtime Hours Worked

: ");

overHours = Integer.parseInt(input.readLine());
System.out.print("Enter Hourly Pay Rate
hourPayRate = Float.parseFloat(input.readLine());

}
void ComputedPay(){
Taxes taxes = new Taxes();

: ");

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
NumberFormat formatter = new DecimalFormat("#000.00");
System.out.println("Computed Gross Pay
P"+formatter.format(grossPay));
if(status.equalsIgnoreCase("m")){
taxes.Married(grossPay, deducted);
System.out.println("\t\t\t\t\t---------------");
taxes.Netpay(grossPay);
grosspay[ctr] = grossPay;
incometax[ctr] = taxes.incomeTax;
netpay[ctr] = taxes.netPay;
ctr++;
}
else if(status.equalsIgnoreCase("s")){
taxes.Single(grossPay, deducted);
System.out.println("\t\t\t\t\t---------------");
taxes.Netpay(grossPay);
grosspay[ctr] = grossPay;
incometax[ctr] = taxes.incomeTax;
netpay[ctr] = taxes.netPay;
ctr++;
}
}
void InputMaritalStatus()throws IOException{
BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));

int x = 0;
x++;
while(x != 0){

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
System.out.print("Enter Marital Status (M or S)

: ");

status = input.readLine();

if(status.equalsIgnoreCase("m")){
x = 0;
}
else if(status.equalsIgnoreCase("s")){
x = 0;
}
else{
System.out.println("Enter 'M' or 'S' only!");
}
}
}
void InputEmployeeNumber()throws IOException{
BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));
int x = 0;
x++;
while(x != 0){
System.out.print("Enter Employee Number
empNum = input.readLine();
if (empNum.length() == 11){
x = 0;
empnum[ctr] = empNum;
}
}
}
void InputDeductions()throws IOException{

: ");

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));

int x = 0;
x++;
while(x != 0){
System.out.print("Enter number of Exemptions taken (0-4) : ");
deductions =Integer.parseInt(input.readLine());
switch (deductions) {
case 0:
x = 0;
break;
case 1:
deducted = 13.50 * 1;
x = 0;
break;
case 2:
deducted = 13.50 * 2;
x = 0;
break;
case 3:
deducted = 13.50 * 3;
x = 0;
break;
case 4:
deducted = 13.50 * 4;
x = 0;
break;
default:

JOHN RHENZ H. JAPSAY


BIT- COMPUTER TECHNOLOGY
4A-G1
}

}
}
void Arrays(){
int x; double grosspayTotal = 0;double incometaxTotal = 0; double netpayTotal
= 0;
NumberFormat formatter = new DecimalFormat("P"+" ##000.00");
System.out.println("Employee

Gross

System.out.println("Number
System.out.println("---------

Pay
-------

Deductions

Net");

Pay");
--------

--------");

for(x = 0;x < ctr;x++){


System.out.println(empnum[x]+"\t"+formatter.format(grosspay[x])+"
"+formatter.format(incometax[x])+"\t
"+formatter.format(netpay[x]));
grosspayTotal += grosspay[x];
incometaxTotal += incometax[x];
netpayTotal += netpay[x];
}
System.out.println("---------

-------

--------

--------");

System.out.println("Totals"+"\t\t"+formatter.format(grosspayTotal)+"
"+formatter.format(incometaxTotal)+"\t
"+formatter.format(netpayTotal));
}

==================================================
================================

Вам также может понравиться