欢迎来到天天文库
浏览记录
ID:17376015
大小:67.50 KB
页数:8页
时间:2018-08-30
《java语言程序设计(基础篇)答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、3.4importjavax.swing.*;publicclassAdditionTutor{publicstaticvoidmain(String[]args){intnumber1=(int)(System.currentTimeMillis()%100);intnumber2=(int)(System.currentTimeMillis()*5%100);StringanswerString=JOptionPane.showInputDialog("whatis"+number1+"+"+number2+"?");intan
2、swer=Integer.parseInt(answerString);JOptionPane.showMessageDialog(null,number1+"+"+number2+"="+answer+"is"+(number1+number2==answer));}}3.10importjavax.swing.JOptionPane;publicclassComputeTaxWithSelectionStatement{publicstaticvoidmain(String[]args){//Prompttheusertoent
3、erfilingstatusStringstatusString=JOptionPane.showInputDialog("Enterthefilingstatus:"+"(0-singlefiler,1-marriedjointly,"+"2-marriedseparately,3-headofhousehold)");intstatus=Integer.parseInt(statusString);//PrompttheusertoentertaxableincomeStringincomeString=JOptionP
4、ane.showInputDialog("Enterthetaxableincome:");doubleincome=Double.parseDouble(incomeString);//Computtaxdoubletax=0;if(status==0){//Computetaxforsinglefilersif(income<=6000)tax=income*0.10;elseif(income<=27950)tax=6000*0.10+(income-6000)*0.15;elseif(income<=67700)tax=60
5、00*0.10+(27950-6000)*0.15+(income-27950)*0.27;elseif(income<=141250)tax=6000*0.10+(27950-6000)*0.15+(67700-27950)*0.27+(income-67700)*0.30;elseif(income<=307050)tax=6000*0.10+(27950-6000)*0.15+(67700-27950)*0.27+(141250-67700)*0.30+(income-141250)*0.35;elsetax=6000*0.1
6、0+(27950-6000)*0.15+(67700-27950)*0.27+(141250-67700)*0.30+(307050-141250)*0.35+(income-307050)*0.386;}elseif(status==1){//Computetaxformarriedfilejointlyif(income<=12000)tax=income*0.10;elseif(income<=46700)tax=12000*0.10+(income-12000)*0.15;elseif(income<=112850)tax=
7、12000*0.10+(46700-12000)*0.15+(income-46700)*0.27;elseif(income<=171950)tax=12000*0.10+(46700-12000)*0.15+(112850-46700)*0.27+(income-112850)*0.30;elseif(income<=307050)tax=12000*0.10+(46700-12000)*0.15+(112850-46700)*0.27+(141250-112850)*0.30+(income-307050)*0.35;else
8、tax=12000*0.10+(46700-12000)*0.15+(112850-46700)*0.27+(171950-112850)*0.30+(307050-171950)*0.35+(income-307050)*0.386
此文档下载收益归作者所有