最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Java練習(xí)

2022-10-13 12:45 作者:沐笙--ms  | 我要投稿

1.計(jì)算個(gè)人所得稅。設(shè)某人月收入為x元,假設(shè)個(gè)人所得稅征收方法如下:

? ? ? 當(dāng)x<=3500時(shí),不需要交稅;

? ? ? 當(dāng)3500<x≤5000時(shí),應(yīng)征稅為(x-3500)* 3%;

? ? ? 當(dāng)5000<x≤8000時(shí),應(yīng)征稅為(x-5000)* 10% + 1500 * 3%;

? ? ? 當(dāng)8000<x≤12500時(shí),應(yīng)征稅為(x-8000)* 20% + 3000 * 10% + 1500 * 3%;

? ? ? 當(dāng)12500<x≤15000時(shí),應(yīng)征稅為(x-12500)* 25% + 4500 * 20% + 3000 * 10% + 1500 * 3%;

? ? ? 當(dāng)15000<x時(shí),應(yīng)征稅為(x-15000)*30% + 2500 * 25% + 4500 * 20% + 3000 * 10% + 1500 * 3%;?


程序運(yùn)行效果如下:

? ? ? ?請(qǐng)輸入個(gè)人收入:

? ? ? ?5000

? ? ? ?個(gè)人所得稅為:45.0

package?? 個(gè)人所得稅;

import java.util.Scanner;

public class Computer{

? ? public static void main(String args[]){

? ? ? ?Scanner reader=new Scanner(System.in);

? ? ? ?double amount=0;? //月收入

? ? ? ?double price=0;? ?//交稅

? ? ? ?System.out.print("輸入個(gè)人約收入(單位元):");

? ? ? ?amount=reader.nextDouble();

? ? ? ?if(amount<=3500 ){

? ? ? ? ? ?price=0;? //計(jì)算3500以?xún)?nèi)所交的稅

? ? ? ?}

? ? ? ?else if(amount<=5000 && amount>3500){

? ? ? ? ? ?price=(amount-3500)*0.03;? //計(jì)算3500以上5000以下的錢(qián)

? ? ? ?}

? ? ? ?else if(amount>5000 && amount<=8000){

? ? ? ? ? ?price=(amount-5000)*0.1+1500*0.03; //計(jì)算5000以上8000以下的錢(qián)

? ? ? ?}

? ? ? ?else if(amount>8000 && amount<=12500){

? ? ? ? ? ?price=(amount-8000)*0.2+3000*0.1+1500*0.03; //計(jì)算8000以上12500以下的錢(qián)

? ? ? ?}

? ? ? ?else if(amount>12500 && amount<=15000){

? ? ? ? ? ?price=(amount-12500)*0.25+12500*0.2+3000*0.1+1500*0.03; //計(jì)算12500以上15000以下的錢(qián)

? ? ? ?}

? ? ? ?else if(amount>15000){

? ? ? ? ? ?price=(amount-15000)*0.3+15000*0.25+12500*0.2+3000*0.1+1500*0.03; //計(jì)算12500以上15000以下的錢(qián)

? ? ? ?}

? ? ? ?else{

? ? ? ? ? ?

? ? ? ? ? ?System.out.println("輸入個(gè)人收入"+amount+"元不合理");

? ? ? ?}

? ? ? ?System.out.printf("個(gè)人所得稅為:%5.1f元",price);

? ? }

}

2、

用 if? else?語(yǔ)句編寫(xiě)程序,從鍵盤(pán)輸入一個(gè)數(shù),判斷它是奇數(shù)還是偶數(shù),并輸出結(jié)果。

選做:把程序改為三目運(yùn)算,并輸出結(jié)果。

package 判斷奇偶;

import java.util.Scanner;

public class judge {

public static void text(){

? ? Scanner input = new Scanner(System.in);

? ? System.out.println("請(qǐng)輸入一個(gè)整數(shù):");? //輸入一個(gè)整數(shù)

? ? int num = input.nextInt();

? ? if(num% 2 == 0)? {

? ? System.out.println(num + "是偶數(shù)");? ?//判斷是否是偶數(shù)

? ? }? else {

? ? ?System.out.println(num + "是奇數(shù)");? //判斷是否是奇數(shù)

}

}

? ? public static void text1() {

? ? ? ? Scanner input = new Scanner(System.in);

? ? ? ? System.out.println("請(qǐng)輸入一個(gè)整數(shù):");? ? ? //輸入一個(gè)整數(shù)

? ? ? ? int num = input.nextInt();

? ? ? ? String str = (num%2==0)? (num + "是偶數(shù)"):(num +"是奇數(shù)");? //判斷是否是奇數(shù)還是偶數(shù)

? ? ? ? System.out.println(str);

? ? }

public static void main(String[] args) {

? ? ? ? text();

? ? ? ? text1();

}

}


Java練習(xí)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
龙南县| 莫力| 登封市| 航空| 连南| 绥宁县| 竹北市| 出国| 屏边| 图木舒克市| 九龙城区| 平度市| 广饶县| 凉城县| 黄梅县| 仲巴县| 桐城市| 甘谷县| 夏邑县| 敦煌市| 光山县| 抚松县| 扶沟县| 城口县| 舟曲县| 大洼县| 柳林县| 邹平县| 巨野县| 富宁县| 蓬安县| 全州县| 黔东| 华池县| 龙游县| 江西省| 黄石市| 怀远县| 三亚市| 吴旗县| 牡丹江市|