本文主要是介绍狗狗每年医疗保险方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
狗狗保险方案
- 方案1: 报销70%,每月3090元
- 方案2: 报销50%,每月2480元
结论 :
年医药费等于36600元时,2种一样。小于36600元,50%方案便宜。大于36600元,70%方案便宜。
package algorithm;public class Test {public static void main(String[] args) {//当2种方案年花销一样时,医疗费用cal();System.out.println("");//医药费小于36600时,50%方案花费便宜compareCost(35000);System.out.println("");//医药费等于36600时,2种方案花费一样compareCost(36600);System.out.println("");//医药费大于36600时,70%方案花费便宜compareCost(37000);}private static void cal() {//differ = 70%方案 - 50%方案//differ = (3090 - 2480) * 12 - 0.2 * cost//differ越大,说明70%的更贵,当2种方案年相差0元时,医疗费用int differ = 0;//随着cost增大,differ变成负数,越来越小,说明70%方案节省的费用随之增大int cost = (7320 - differ) * 5;System.out.println("cost = " + cost);}private static double method1(int cost) {//70%方案一年花费double total1 = 3090 * 12 + 0.3 * cost;System.out.println("70%方案,医疗+保险/年 = " + total1);return total1;}private static double method2(int cost) {//50%方案一年花费double total2 = 2480 * 12 + 0.5 * cost;System.out.println("50%方案,医疗+保险/年 = " + total2);return total2;}private static void compareCost(int cost) {System.out.println("医药费 = " + cost);double differ = method1(cost) - method2(cost);if (differ < 0) {System.out.println("70%方案便宜了 = " + Math.abs(differ));} else if (differ == 0) {System.out.println("2种方案花费一样");} else {System.out.println("50%方案便宜了 = " + differ);}}
}
这篇关于狗狗每年医疗保险方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!