retire or not retire ? is a question.
2016-12-09 18:11
225 查看
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")); } }
相关文章推荐
- to be or not to be, that is a question...
- 80 after generation to marry or not to marry is a question
- To Be Or Not To Be Is The Question
- 当我开始写这篇文章时,我想起的莎翁的一句话:To be or not to be ,That is a question.
- To Be a Coder or Not, That's a Question!
- To Be a Coder or Not, That's a Question!
- 80 after generation to marry or not to marry that is a question
- To be, or not to be; that is the question! 生存还是毁灭,这是个值得思考的问题。
- to be or not to be this is a question
- 当IE向服务器发送数据的时候,这些数据是IE从哪里取得的呢?To block, or not to block? That is the question.
- To learn, or not to learn Windows Mobile - that is the question
- To be or not to be that is a question
- Android Question - “Id cannot be resolved or is not a field” error?
- 莎士比亚说:To be or not to be, that’s a question是什么意思?
- to NGen or not to NGen, that is the question
- “To be or not to be, that is the question”
- 1092. To Buy or Not to Buy (20)
- adstpall.sh: Database connection could not be established. Either the database is down or the APPS c
- locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
- Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix