# 复利值 # 计算CD价值 # 求销售总额
复利值
每月存100,年利率5%,存6个,月帐面价值多少?
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入每月存款额:");
double monthlySaveAmount = input.nextDouble();
System.out.print("请输入年利率:");
double annuallyInterestRate = input.nextDouble();
double monthlyInterestRate = annuallyInterestRate / 1200;
System.out.print("请输入存入月份:");
int numbersOfMonth = input.nextInt();
double amoutOfMoney = 0;
for(int i = 0; i < numbersOfMonth; i++){
amoutOfMoney = amoutOfMoney + monthlySaveAmount;
amoutOfMoney = amoutOfMoney * (1 + monthlyInterestRate);
}
System.out.print("第" + numbersOfMonth + "个月的帐面值为:");
System.out.printf("%7.3f",amoutOfMoney);
input.close();
}
}
计算CD价值
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the initial deposit amount: ");
double amount = input.nextDouble();
System.out.print("Enter annual percentage yield: ");
double annuallyInterestRate = input.nextDouble();
double monthlyInterestRate = annuallyInterestRate / 1200;
System.out.print("Enter maturity period (number of months): ");
int numbersOfMonth = input.nextInt();
System.out.print("Month\tCD Value");
double valueOfCD = amount;
for(int i = 1; i <= numbersOfMonth; i++){
valueOfCD *= (1 + monthlyInterestRate);
System.out.printf("\n" + i + "\t\t" + "%-8.2f", valueOfCD);
}
input.close();
}
}
求销售总额
基本工资5000+提成,挣30,000需要多少销售额
import java.util.Scanner;
class Main {
public static void main(String[] args){
double saleAmount = 0;
double salary = 0;
do{
if(saleAmount <= 5000)
salary = 5000 + saleAmount * 0.08;
if(saleAmount > 5000 && saleAmount <= 10_000)
salary = 5000 + 5000 * 0.08 + (saleAmount - 5000) * 0.10;
if(saleAmount > 10_000)
salary = 5000 + 5000 * 0.08 +(10_000 - 5000) * 0.10 + (saleAmount - 10_000) * 0.12;
saleAmount++;
}while(salary < 30_000);
System.out.println("The Sale Amount is: " + saleAmount);
}
}

浙公网安备 33010602011771号