# 复利值 # 计算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);
 }
}

posted @   Scenery_Shelley  阅读(47)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示