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"));
}
}
retire or not retire ? is a question.的更多相关文章
- .保护Express应用程序
毫无疑问,Node.js已经变的愈加成熟,尽管这样,开发者仍然缺乏大量的安全指南.在这篇文章中,我将分享一些有关Node.js安全要点给大家,希望大家能够谨记于心. 1.避免使用Eval Eval并不 ...
- Understanding G1 GC Logs--转载
原文地址:https://blogs.oracle.com/poonam/entry/understanding_g1_gc_logs Understanding G1 GC Logs By Poon ...
- EOS基础全家桶(十四)智能合约进阶
简介 通过上一期的学习,大家应该能写一些简单的功能了,但是在实际生产中的功能需求往往要复杂很多,今天我就继续和大家分享下智能合约中的一些高级用法和功能. 使用docker编译 如果你需要使用不同版本的 ...
- 全网最硬核 JVM TLAB 分析(单篇版不包含额外加菜)
今天,又是干货满满的一天.这是全网最硬核 JVM 系列的开篇,首先从 TLAB 开始.由于文章很长,每个人阅读习惯不同,所以特此拆成单篇版和多篇版 全网最硬核 JVM TLAB 分析(单篇版不包含额外 ...
- retire
retire 本来抱着进队的决心迎战,结果在第一试就失利,是能力不足,还是命中注定我不是竞赛的料,一切关于OI的事随着GDOI2016的闭幕而消散-- 今后也许再也不搞OI了,或许会玩一下ACM,现在 ...
- Timberwolves forward Kevin Garnett to retire _洛杉矶时报
Timerwolves:森林狼队,forward:前锋; kevin Garnett,the best player in Minnesota Timberwolves history,is expe ...
- an interview question(1)
声明:本文为博主原创文章,未经博主允许不得转载. 以下是英文翻译: warnning: Copyright!you can't reprint this blog when you not get b ...
- nullcon HackIM 2016 -- Crypto Question 1
You are in this GAME. A critical mission, and you are surrounded by the beauties, ready to shed thei ...
- Stack Overflow is a question and answer site
http://stackoverflow.com/ _ Stack Overflow is a question and answer site for professional and enthus ...
随机推荐
- Hibernate,Session方法使得java对象进入持久化状态;持久化对象特征
以下情况java对象进入持久化状态: session.save()方法把临时对象转变为持久化对象. session.load()和session.get()方法得到的对象总是处于持久化状态. sess ...
- C#:实现托盘
1.向窗体上添加如下控件:MenuStrip menuStrip1, NotifyIcon ni_frmMain,Timer timer1, ContentMenuStrip cms_notify.其 ...
- jqeury.base
min.js //前台调用 var $ = function (args) { return new Base(args); } //基础库 function Base(args) { //创建一个数 ...
- 让ecshop用户登录评价以可择匿名评价
ECSHOP 默认的程序 是 当用户登录后,对商品商品评价是不是能匿名评价的. 有些店铺设置了只能登录评价,但客户又不想显示自己的账号名称.这时候 这功能 就可以派上用场了 1在 comment.ph ...
- json返回日期格式化的解决
function jsonDateFormat(jsonDate) {//json日期格式转换为正常格式 try { var date = new Date(parseInt(jsonDate.rep ...
- java 1G大文件复制
对比几种复制方法 复制的文件是980m的txt文件 1. FileChannel 方法 代码: public static void mappedBuffer() throws IOExceptio ...
- Java中的ClassLoader
Java中类的加载过程(如Dog类): 通过类型信息定位Dog.class文件. 载入Dog.class文件,创建相应的Class对象. 执行父类的静态字段定义时初始化语句和父类的静态初始化块 ...
- JQuery的$(document).ready(function(){})与JS的window.onload 的各自优势!
由于项目需要,使用JQuery也有相当一段时间了.由于经常要处理DOM节点加载.图片显示以及动态资源请求,所以对$(document).ready(function(){})理解也越来越深了,所有在此 ...
- UVa 1339,紫书P73,词频
题目链接:https://uva.onlinejudge.org/external/13/1339.pdf 紫书P73 解题报告: #include <stdio.h> #include ...
- 最流行的编程语言JavaScript能做什么?
本文转自互联网! 首先很遗憾的一点是,"PHP虽然是最好的语言",但是它不是最流行的语言. 对不起的还有刚刚在4月TIOBE编程语言排行榜上榜的各个语言: 你们都很棒,但是你们都担 ...