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的更多相关文章

  1. JAVA HW2

    MODEL //yuec2 Yue Cheng package hw2; import java.io.File; import java.io.FileNotFoundException; impo ...

  2. Software Testing hw2

    Fault的定义:可能导致系统或功能失效的异常条件(Abnormal condition that can cause an element or an item tofail.),可译为“故障”. ...

  3. HW2.25

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. HW2.24

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  5. HW2.23

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW2.22

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW2.21

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  8. HW2.20

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  9. HW2.19

    public class Solution { public static void main(String[] args) { char outcome; long randomNumber; wh ...

  10. HW2.18

    public class Solution { public static void main(String[] args) { System.out.println("a" + ...

随机推荐

  1. python zookeeper 学习笔记

    1.安装zookeeper 下载zookeeper后,解压,安装 cd zookeeper-/src/c ./configure make make install 2.启动zookeeper服务 c ...

  2. C# zip/unzip with DotNet framework 4.5

    add reference System.IO.Compression.FileSystem public class ZipHelper { public static string UnZip(s ...

  3. css3360度旋转动画

    @-webkit-keyframes Parallaxs{ from { -webkit-transform: rotate(180deg) ; -moz-transform: rotate(180d ...

  4. ASP.net 的URL路由选择(System.Web.Routing.dll)

    System.Web.Routing是.net 3.5sp1中新增的一个dll,用它提拱的类可以很方便的实现url的映射,在asp.net WebFrom的编程中可以使客户端请求的URL变得更加的&q ...

  5. 数据库备份,远程执行SHELL脚本

    小小的东东,用于数据库的备份. 留存. #!/bin/sh keepDays= currentTime=`date "+%Y-%m-%d-%H-%M"` backPath=&quo ...

  6. http://blog.csdn.net/zhang_xinxiu/article/details/38655311

    一.Activiti下载及简介 1.1.Activiti下载 官网下载地址:http://activiti.org/download.html        Note:下载时不一定要使用最新版本的,最 ...

  7. UVA 1160 X-Plosives

    题意是一次装入物品,物品由两种元素组成,当遇到即将装入的物品与已经装入的物品形成k个物品,k种元素,跳过该物品的装入.可以将每种元素看成顶点,物品看成一条边.这样问题就转化为利用并查集求环的情况. 算 ...

  8. RUST叫系统编程语言,而GO是网络编程语言

    用GO你必须要搞清楚一点,GO不是面向CPU密集计算的,而是面向IO密集计算的!!!RUST才是面向CPU密集计算的语言,所以RUST叫系统编程语言,而GO是网络编程语言.GO跟JAVA的Spring ...

  9. 你所不知道的string.xml

    String 能被应用程序或者其他资源文件(比如layout XML)引用的单个字符串. 注意:字符串是简单类型资源,是用名称(name)(而非XML文件名)来直接引用的.因此,在一个XML文件里,可 ...

  10. C#操作Access

    C#操作Access数据库的基础知识浅析 C#操作Access数据库的基础知识都有什么呢? C#操作Access数据库的基础知识1. 通过ADO.NET的OleDb相关类来操作Access 主要知识点 ...