java計算工資代碼 java計算工資及所得稅

java計算工資

person類:

我們注重客戶提出的每個要求,我們充分考慮每一個細節(jié),我們積極的做好成都網(wǎng)站制作、網(wǎng)站設(shè)計服務(wù),我們努力開拓更好的視野,通過不懈的努力,創(chuàng)新互聯(lián)建站贏得了業(yè)內(nèi)的良好聲譽,這一切,也不斷的激勵著我們更好的服務(wù)客戶。 主要業(yè)務(wù):網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)站設(shè)計,小程序設(shè)計,網(wǎng)站開發(fā),技術(shù)開發(fā)實力,DIV+CSS,PHP及ASP,ASP.Net,SQL數(shù)據(jù)庫的技術(shù)開發(fā)工程師。

public abstract class Person {

public double pay; // 總工資

public int hour; // 課時

public double countPay(int hour) {

return pay;

}

}

助教類:

public class Assistant extends Person {

public final double BASE_PAY = 800; // 基本工資

public final double HOUR_PAY = 25; // 每課時的費用

public double countPay(int hour) {

pay = BASE_PAY + hour * HOUR_PAY;

return pay;

}

}

講師類:

public class Instructor extends Person {

public final double BASE_PAY = 1000; // 基本工資

public final double HOUR_PAY = 35; // 每課時的費用

public double countPay(int hour) {

pay = BASE_PAY + hour * HOUR_PAY;

return pay;

}

}

副教授類:

public class AssistantProfesson extends Person {

public final double BASE_PAY = 1200; // 基本工資

public final double HOUR_PAY = 40; // 每課時的費用

public double countPay(int hour) {

pay = BASE_PAY + hour * HOUR_PAY;

return pay;

}

}

教授類:

public class Professor extends Person {

public final double BASE_PAY = 1400; // 基本工資

public final double HOUR_PAY = 50; // 每課時的費用

public double countPay(int hour) {

pay = BASE_PAY + hour * HOUR_PAY;

return pay;

}

}

測試類:

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class Test {

public static void main(String[] args) {

System.out.println("人員類型如下:");

System.out.println("1 = 助教\r\n2 = 講師\r\n3 = 副教授\r\n4 = 教授");

System.out.print("請選擇:");

BufferedReader personType = new BufferedReader(new InputStreamReader(

System.in));

String type = null;

int hour = 0;

try {

type = personType.readLine();

} catch (Exception e) {

e.printStackTrace();

}

if (type.matches("[1-4]{1}")) {

switch (Integer.valueOf(type)) {

case 1:

hour = getHour();

if(hour == 0){return;}

Person p1 = new Assistant();

double pay1 = p1.countPay(hour);

System.out.println("助教工作" + hour + "課時的工資為:" + pay1);

break;

case 2:

hour = getHour();

if(hour == 0){return;}

Person p2 = new Instructor();

double pay2 = p2.countPay(hour);

System.out.println("講師工作" + hour + "課時的工資為:" + pay2);

break;

case 3:

hour = getHour();

if(hour == 0){return;}

Person p3 = new AssistantProfesson();

double pay3 = p3.countPay(hour);

System.out.println("副教授工作" + hour + "課時的工資為:" + pay3);

break;

case 4:

hour = getHour();

if(hour == 0){return;}

Person p4 = new Professor();

double pay4 = p4.countPay(hour);

System.out.println("教授工作" + hour + "課時的工資為:" + pay4);

break;

}

} else {

System.out.println("輸入數(shù)據(jù)錯誤!程序提前推出!");

return;

}

}

public static int getHour() {

System.out.print("請輸入工作時間:");

BufferedReader hours = new BufferedReader(new InputStreamReader(

System.in));

String strHour = null;

int hour = 0;

try {

strHour = hours.readLine();

} catch (Exception e) {

e.printStackTrace();

}

if (strHour.matches("^[0-9]+?")) {

hour = Integer.parseInt(strHour);

} else {

System.out.println("輸入?yún)?shù)不正確!程序提前推出!");

}

return hour;

}

}

java算工資的編程題?

class Salary{

private int no;

private String name;

private double deal;

private double tax;

public Salary(int no,String name,double deal,double tax){

this.no=no;

this.name=name;

this.deal=deal;

this.tax=tax;

}

public double count(){

return this.deal-this.tax;

}

public void output(){

System.out.println("工號"+this.no);

System.out.println("姓名"+this.name);

System.out.println("應(yīng)發(fā)工資"+this.deal);

System.out.println("稅金"+this.tax);

System.out.println("實發(fā)工資"+count());

}

public static void main(String[] args){

Salary a=new Salary(1,"張三",1000,200);

a.output();

Salary b=new Salary(2,"李四",1500,200);

b.output();

}

}

怎樣計算工資包括年工資,周工資,月工資,用java編寫程序

代碼一

public double earnings()

{double a=50000.456;

return a;

}

代碼二

public double earnings()

{double b=2000;

return 12*b;}

代碼三

public double earnings()

{double c=500;

return 52*c;}

代碼四

我也正在思考中

標題名稱:java計算工資代碼 java計算工資及所得稅
文章來源:http://muchs.cn/article36/ddcgcpg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、自適應(yīng)網(wǎng)站、微信小程序、搜索引擎優(yōu)化小程序開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管