retire or not retire ? is a question.

corejava 上的一段代码 因吹思婷

"C:\Program Files\Java\jdk1.8.0_101\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_101\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_101\jre\lib\rt.jar;D:\MyTest\out\production\MyTest;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain MyTest
How much money will you contribute every year
2700
Internet rate in %:
0.1
After year 1,your balance is 2,702.70
Ready to retire?(Y/N)N
After year 2,your balance is 5,408.10
Ready to retire?(Y/N)N
After year 3,your balance is 8,116.21
Ready to retire?(Y/N)N
After year 4,your balance is 10,827.03
Ready to retire?(Y/N)N
After year 5,your balance is 13,540.55
Ready to retire?(Y/N)N
After year 6,your balance is 16,256.79
Ready to retire?(Y/N)N
After year 7,your balance is 18,975.75
Ready to retire?(Y/N)N
After year 8,your balance is 21,697.43
Ready to retire?(Y/N)
import java.util.*;

public class MyTest{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        System.out.print("How much money will you contribute every year");
        double payment = in.nextDouble();

        System.out.print("Internet rate in %: ");
        double interestRate = in.nextDouble();

        double balance = 0;
        int year = 0;

        String input;

        //update account balance while user isn‘t ready to retire
        do{
            //add this year‘s payment and interest
            balance += payment;
            double interest = balance * interestRate / 100;
            balance += interest;

            year++;

            //print current balance
            System.out.printf("After year %d,your balance is %,.2f%n", year, balance);

            //ask if ready to retire and get input
            System.out.print("Ready to retire?(Y/N)");
            input = in.next();
        }while(input.equals("N"));
    }
}
时间: 2024-12-07 18:23:44

retire or not retire ? is a question.的相关文章

.保护Express应用程序

毫无疑问,Node.js已经变的愈加成熟,尽管这样,开发者仍然缺乏大量的安全指南.在这篇文章中,我将分享一些有关Node.js安全要点给大家,希望大家能够谨记于心. 1.避免使用Eval Eval并不是唯一一个需要避免的函数,在后台,下面这几个表达式可以使用eval: setInterval(String, 2)setTimeout(String, 2)new Function(String) 为什么要禁止使用eval?因为它 会打开代码引起注入攻击,并且降低运行速度. 2.请用严苛模式(Str

是否通过技术任霆发够使肌肤

http://www.gome.com.cn/search?question=%E5%8F%B0%E5%B7%9E%E6%96%B0%E6%A1%A5%E9%95%87%e6%89%be%e5%b0%8f%e5%a7%90%e4%b8%8a%e9%97%a8%e6%9c%8d%e5%8a%a11858885v7572 http://www.gome.com.cn/search?question=%E5%8F%B0%E5%B7%9E%E6%96%B0%E6%A1%A5%E9%95%87%e6%89

榔举料昧卣pn5vu85bwh7a68krk

新华社瓦莱塔4月10日电(记者李拯宇 李佳)全国政协主席俞正声10日在前往非洲三国进行正式友好访问途中过境马耳他,在瓦莱塔会见马耳他议长法鲁贾. 俞正声说,中马保持长期友好关系,政治上相互信任,经济上密切合作,人文交流不断深化.中方感谢马方在中国撤侨行动中给予的支持和帮助.中方愿同马方一道,落实两国领导人达成的共识,弘扬中马传统友好,拓展在科技.渔业.旅游等领域互利合作,打造合作新亮点.中国全国政协愿与马耳他议会和社会各界保持密切交往,加强治国理政经验交流,为两国扩大务实合作营造良好环境,共同促

Timberwolves forward Kevin Garnett to retire _洛杉矶时报

Timerwolves:森林狼队,forward:前锋; kevin Garnett,the best player in Minnesota Timberwolves history,is expected  to announce his retirement soon after reaching a buyout aggreement with the club,multiple sources have confirmed. Minnesota:明尼苏达州(美国);is expecte

【Q&A】12C OCP 1z0-060 QUESTION 1: About Managing Temporary Tablespaces in a CDB

QUESTION 1 Your multitenant container (CDB) contains two pluggable databases (PDB), HR_PDB and ACCOUNTS_PDB, both of which use the CDB tablespace. The temp file is called temp01.tmp. A user issues a query on a table on one of the PDBs and receives th

nullcon HackIM 2016 -- Crypto Question 1

You are in this GAME. A critical mission, and you are surrounded by the beauties, ready to shed their slik gowns on your beck. On onside your feelings are pulling you apart and another side you are called by the duty. The biggiest question is seX OR

Question about of Softlayer IPSec

http://w3.insidepacket.net/index.php/16-softlayer-ipsec-4 Recently, one Softlayer customer complained that they have issue when the servers on the corporate network talk to VM guest on Softlayer.  They found that their VM guests in Softlayer always s

Chapter7: question 49 - 50

49. 把字符串转换为整数 很多细节需要注意.(空格,符号,溢出等) Go: 8. String to Integer (atoi) 50. 树种两个结点的最低公共祖先 A. 若是二叉搜索树,直接与根结点对比. 若都大于根节点,则在友子树:若都小于根节点,则在左子树:若根节点介于两数之间,则根节点即为答案. B. 普通树,若是孩子节点有指向父节点的指针,则问题变为求两个链表的第一个公共结点. 如:37题. C. 普通树:思路1,若一个结点的子树同时包含两个结点,而它的任一孩子结点的子树却不能同时

zoj 1763 A Simple Question of Chemistry

A Simple Question of Chemistry Time Limit: 2 Seconds      Memory Limit: 65536 KB Your chemistry lab instructor is a very enthusiastic graduate student who clearly has forgotten what their undergraduate Chemistry 101 lab experience was like. Your inst