package test2_10;
/*
* 天天向上实例
*/
import java.util.Scanner;
public class Test2_10 {
public static void main(String[] args) {
//提示用户输入向上的天数和进步程度
System.out.println("请输入向上的天数>");
Scanner sc = new Scanner(System.in);
int upday = sc.nextInt();
System.out.println("请输入进步程度(%)>");
int up = sc.nextInt();
System.out.println("请输入没有向上的天数>");
int lowday = sc.nextInt();
System.out.println("请输入退步程度(%)>");
int low = sc.nextInt();
//计算两者相差多少倍
double differ = Math.pow((1+0.01*up),upday)-Math.pow((1-0.01)*low,lowday);
System.out.println("两者相差>"+differ+"倍");
}
}
天天向上实例的 java-code
于 2022-02-11 17:14:03 首次发布