HW2.9

import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter an amount in int, for example 1156: ");
int amount = input.nextInt();
int remainingAmount = amount;
input.close();
int numberOfOneDollars = remainingAmount / 100;
remainingAmount = remainingAmount % 100;
int numberOfQuarters = remainingAmount / 25;
remainingAmount = remainingAmount % 25;
int numberOfDimes = remainingAmount / 10;
remainingAmount = remainingAmount % 10;
int numberOfNickels = remainingAmount / 5;
remainingAmount = remainingAmount % 5;
int numberOfPennis = remainingAmount;
System.out.println("Your amount " + amount + " consists of \n" +
"\t" + numberOfOneDollars + " dollars\n" +
"\t" + numberOfQuarters + " quarters\n" +
"\t" + numberOfDimes + " dimes\n" +
"\t" + numberOfNickels + " nickels\n" +
"\t" + numberOfPennis + " pennis");
}
}
HW2.9的更多相关文章
- JAVA HW2
MODEL //yuec2 Yue Cheng package hw2; import java.io.File; import java.io.FileNotFoundException; impo ...
- Software Testing hw2
Fault的定义:可能导致系统或功能失效的异常条件(Abnormal condition that can cause an element or an item tofail.),可译为“故障”. ...
- HW2.25
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.24
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.23
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.22
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.21
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.20
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.19
public class Solution { public static void main(String[] args) { char outcome; long randomNumber; wh ...
- HW2.18
public class Solution { public static void main(String[] args) { System.out.println("a" + ...
随机推荐
- 创建一个.bat文件,用于打开某个路径下的文件
- MSSql ID自动增长删除数据重1开始
dbcc checkident('db_Tome1.dbo.员工信息表',reseed,0) 注:dbcc checkident('表名',reseed,0)
- Google地图数据算法
Google Maps与Google Earth中的每个级别的每一副图片都有一个URL,例如下面这幅我们学校的图的地址是http://kh.google.com/kh?v=3&t=trstrq ...
- oracle 内置函数 least decode
在博客园的第一个博客,为什么叫第一个.... oracle 内置函数 east(1,2,3,4.....) 可以有多个值,最多几个?不知道欢迎补充 ,,,) from dual 这个函数返回是1,就是 ...
- GC的代机制
1.代为CLR垃圾回收器采用的一种机制,基于以下几点假设:对象越新,生存期越短:对象越老,生存期越长: 2.托管堆仅支持3代(GC.MaxGeneration,第0代.第1代.第2代),CLR初始化会 ...
- cursor:hand与cursor:pointer的区别介绍
cursor:hand 与 cursor:pointer 的效果是一样的,都像光标指向链接一样,光标变成手行. cursor:hand :IE完全支持.但是在firefox是不支持的,没有效果. cu ...
- JavaScript闭包底层解析
1. 闭包是一个函数,这个函数有权访问另一个函数作用域中的变量,创建闭包最常见的方式,就是在函数内部创建函数.要想彻底搞清其中细节,必须从函数从创建到调用的时候都发生了什么入手 2. 函数第一次被调用 ...
- BZOJ 1729: [Usaco2005 dec]Cow Patterns 牛的模式匹配
Description 约翰的N(1≤N≤100000)只奶牛中出现了K(1≤K≤25000)只爱惹麻烦的坏蛋.奶牛们按一定的顺序排队的时候,这些坏蛋总会站在一起.为了找出这些坏蛋,约翰让他的奶牛排好 ...
- 各大搜索引擎的User-Agent
baidu:Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html) Google:Moz ...
- Ubuntu14.04强化之conky——Harmattan主题
一共有17个主题,四种模式,两种天气模式,支持摄氏度和华氏度. This conky comes with 17 themes: Cards Elementary Elune Flatts Metro ...