中易网

java求大神

答案:2  悬赏:0  
解决时间 2021-02-14 21:04
java求大神
最佳答案
package com.simple.standard;

import java.util.Scanner;

public class IntSvcAdvisor {

private static Scanner sc;
private static final String SET_A = "A";
private static final String SET_B = "B";
private static final String SET_C = "C";

public static void main(String[] args) {
sc = new Scanner(System.in);
// User set
String set = "";
// Duration
int hours = 0;

// Choose set.
System.out.print("Choose your set(A, B or C): ");
// Get user choice from keyboard.
set = sc.next();

// input hours
System.out.println("Input your hours: ");
// Get user choice from keyboard.
hours = sc.nextInt();

// Process according to user choice.
double acturalCost = calCostOfMonth(set, hours);
System.out.println(acturalCost);

outputAnalysisResult(set, hours, acturalCost);

}

private static double calCostOfMonth(String setName, int hours) {
double cost = 0;

switch (setName.toUpperCase()) {
// 套餐A:
case "A":
// 对于每月9.95美元,提供10小时访问。更多的时间是2.00美元每小时。
cost = hours > 10 ? (hours - 10) * 2 + 9.95 : 9.95;
break;
// 套餐B:
case "B":
// 对于13.95美元每月提供20小时访问。更多的时间是1.00美元每小时。
cost = hours > 20 ? (hours - 20) * 1 + 13.95 : 13.95;
break;
// 套餐C:
case "C":
// 对于每月19.95美元的无限接入提供。
cost = 19.95;
break;

default:
break;

}
return cost;

}

private static void outputAnalysisResult(String setName, int hours,
double actualCost) {
double saveForB = 0;
double saveForC = 0;

if (actualCost > 0 || SET_C.equals(setName.toUpperCase())) {
if (setName.toUpperCase().equals(SET_A)) {
saveForB = actualCost - calCostOfMonth(SET_B, hours);
if (saveForB > 0) {
System.out.println("如果购买套餐B, 将有可能节省: $" + saveForB);
}

saveForC = actualCost - calCostOfMonth(SET_C, hours);
if (saveForB > 0) {
System.out.println("如果购买套餐C, 将有可能节省: $" + saveForC);
}

} else if (setName.toUpperCase().equals(SET_B)) {
saveForC = actualCost - calCostOfMonth(SET_C, hours);
if (saveForB > 0) {
System.out.println("如果购买套餐C, 将有可能节省: $" + saveForC);
}
}
}
}
}
全部回答
<p>先说一下这个代码是我找的,可以参考一下 </p> public static void main(string[] args) { // todo auto-generated method stub biginteger one = biginteger.one; biginteger ten = biginteger.ten; biginteger a = one; biginteger b = one.add(one.add(one)); biginteger c = b; biginteger sum = biginteger.one; for(int i=0;i&lt;300;i++){//需要精确到100位,所以循环次数要适当 sum = a; for(int j=0;j&lt;101;j++){//需要把小数点向右移动101位 sum = ten.multiply(sum); } biginteger res = sum.divide(c); c = a.add(b); a = b; b = c; if(res.tostring().length()==101){//要判断到101位,需要四舍五入 system.out.println(res); } }
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
天龙八部宝藏洞5层木桶伯几级能打
现在学校都是九年义务教学了,可老师还是经常
植物大战僵尸里面种的那棵树有高度极限吗?
dark和black有什么区别
北京彩梅布鞋NO.008地址在哪,我要去那里办事
途锐v6的标识,V6Ts丨多少钱?
鹿鼎记如何更换职业?
厦航兑换积分不够可以用钱吗?
湖北定园机械公司地址在哪,我要去那里办事
DNF什么职业最好赚钱啊?
延边吉兴典当有限公司地址有知道的么?有点事
急求个个性响亮的夜总会口号
表格,长方形,长7cm,宽3cm,周长多少
为什么总是感觉便不尽????
电子管收音头售价是多少
推荐资讯
谁能给个WIN7原版系统,我找了个貌似不是,用
私立医院的定义是?
贾玲年代秀说的韩语什么意思
大红妈咪宝贝生活坊(旗舰店)这个地址在什么地
“最新的”英语单词以L开头的是哪个,“报道
SEPHORA(园融星座购物中心店)怎么去啊,有知
浮梁县林权管理服务中心这个地址在什么地方,
汉江医院恒通口腔诊所地址在什么地方,想过去
科目二陪练一小时多少钱 能提供场地的 上班
B365水果孝素减肥效果好吗
08年后国家把每年的5月12定为什么日
贾汪新工区原来的圆盘道,现在改成了红绿灯路
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?