日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

0317复利计算3.0

發(fā)布時(shí)間:2025/5/22 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 0317复利计算3.0 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1 package kxj; 2 import java.util.Scanner; 3 4 public class Fulijisuan { 5 public static double p,i,f ; 6 public static double n; 7 8 //計(jì)算本金 9 public static void Benjin(){ 10 //int n; 11 //float f,i,p; 12 Scanner scanner=new Scanner(System.in); 13 System.out.println("請(qǐng)輸入終值: "); 14 f=scanner.nextDouble(); 15 System.out.println("請(qǐng)輸入年利率: "); 16 i=scanner.nextDouble(); 17 System.out.println("請(qǐng)輸入年數(shù): "); 18 n=scanner.nextInt(); 19 p=(float) (f*1/Math.pow(1+i, n)); 20 System.out.println("本金為: "+(double)(Math.round(p*100)/100.0)); 21 22 } 23 24 //計(jì)算本息和 25 public static void Benxihe(){ 26 double sum1,sum2; 27 Scanner scanner=new Scanner(System.in); 28 System.out.println("請(qǐng)輸入本金: "); 29 p=scanner.nextDouble(); 30 System.out.println("請(qǐng)輸入年利率: "); 31 i=scanner.nextDouble(); 32 System.out.println("請(qǐng)輸入年數(shù): "); 33 n=scanner.nextInt(); 34 sum1=(float) (p*Math.pow(1+i, n)); 35 sum2=p*(1+i*n); 36 System.out.println("復(fù)利的本息和為: "+(double)(Math.round(sum1*100)/100.0)); 37 System.out.println("單利的本息和為: "+(double)(Math.round(sum2*100)/100.0)); 38 } 39 40 //計(jì)算年數(shù) 41 public static void Nianshu(){ 42 Scanner scanner=new Scanner(System.in); 43 System.out.println("請(qǐng)輸入本金: "); 44 p=scanner.nextDouble(); 45 System.out.println("請(qǐng)輸入終值: "); 46 f=scanner.nextDouble(); 47 System.out.println("請(qǐng)輸入年利率: "); 48 i=scanner.nextDouble(); 49 n=Logarithm.log(f/p,1+i); 50 n=Math.ceil(n); 51 System.out.println("需要存的年數(shù)為: "+Math.ceil(n)); 52 } 53 54 //計(jì)算年利率 55 public static void Lilv(){ 56 Scanner scanner=new Scanner(System.in); 57 System.out.println("請(qǐng)輸入本金: "); 58 p=scanner.nextDouble(); 59 System.out.println("請(qǐng)輸入終值: "); 60 f=scanner.nextDouble(); 61 System.out.println("請(qǐng)輸入年數(shù): "); 62 n=scanner.nextInt(); 63 i=Math.pow(f/p, 1.0/n)-1; 64 System.out.println("年報(bào)酬率為: "+(double)(Math.round(i*1000)/1000.0)); 65 } 66 67 //計(jì)算本利之和連同年金投資后的總資產(chǎn) 68 public static void Nianjin(){ 69 int k=1; 70 f=0; 71 Scanner scanner=new Scanner(System.in); 72 System.out.println("請(qǐng)輸入本金: "); 73 p=scanner.nextDouble(); 74 System.out.println("請(qǐng)輸入年利率: "); 75 i=scanner.nextDouble(); 76 System.out.println("請(qǐng)輸入年數(shù): "); 77 n=scanner.nextInt(); 78 while(k<=n){ 79 p=p+f; 80 f=p*(1+i); 81 k++; 82 } 83 System.out.println("年資產(chǎn)總值為:"+(int)f); 84 } 85 86 87 public static void main(String[] args) { 88 int choice; 89 while(true){ 90 System.out.println("\t\t|*******************|"); 91 System.out.println("\t\t| 1.求本金 |"); 92 System.out.println("\t\t| 2.求本息和 |"); 93 System.out.println("\t\t| 3.求年數(shù) |"); 94 System.out.println("\t\t| 4.求利率 |"); 95 System.out.println("\t\t| 5.求年資產(chǎn)總值 |"); 96 System.out.println("\t\t| 6.退出 |"); 97 System.out.println("\t\t|*************|"); 98 Scanner scanner=new Scanner(System.in); 99 System.out.println("請(qǐng)輸入你的選擇(1~6): "); 100 choice=scanner.nextInt(); 101 switch(choice){ 102 case 1: 103 Benjin(); 104 break; 105 case 2: 106 Benxihe(); 107 break; 108 case 3: 109 Nianshu(); 110 break; 111 case 4: 112 Lilv(); 113 break; 114 case 5: 115 Nianjin(); 116 break; 117 case 6: 118 System.exit(0); 119 break; 120 default: 121 { 122 System.out.println("輸入有誤!"); 123 break; 124 } 125 } 126 } 127 } 128 } 1 package kxj; 2 3 public class Logarithm { 4 static public double log(double value, double base){ 5 return Math.log(value)/Math.log(base); 6 7 } 8 }

?功能說(shuō)明:

新增了計(jì)算期限、年利率,以及每年都將本利和連同年金投入獲得的年資產(chǎn)總值的功能。

轉(zhuǎn)載于:https://www.cnblogs.com/950525kxj/p/5288200.html

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的0317复利计算3.0的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。