访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容
k =sca.Double();
Double k = sca.nextDouble();
Double k = 3.5;
//import java.util.Scanner; public class tst001{ public static void main(String args[]){ //Scanner sca = new Scanner(System.in); System.out.println("第5题,请设计Java程式计算网路购物的运费,基本物流处理费199,1~5公斤,每公斤50元,超过5公斤,每一公斤为30元,目前购物重量为3.5、10、25公斤后,计算和显示购物所需的运费+物流处理费?"); //System.out.println("请输入您物品的重量:"); Double k = 3.5; Double sum = 199.0; if(k > 5.0){ sum += 250; k = k - 5.0; sum = sum + ((int)(k * 30.0)); }else{ sum = sum + ((int)(k * 50)); } System.out.println(k + "公斤的物流费为:" + sum ); //----------K带入第二个数据 10 k = 10.0; sum = 199.0; if(k > 5.0){ sum += 250; k = k - 5.0; sum = sum + ((int)(k * 30.0)); }else{ sum = sum + ((int)(k * 50)); } System.out.println(k + "公斤的物流费为:" + sum ); //----------K带入第二个数据 25 k = 25.0; sum = 199.0; if(k > 5.0){ sum += 250; k = k - 5.0; sum = sum + ((int)(k * 30.0)); }else{ sum = sum + ((int)(k * 50)); } System.out.println(k + "公斤的物流费为:" + sum ); } }