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. Nginx+uWSGI+bottle 在Linux上部署

    在/data/lujianxing/bottle 文件夹中创建三个文件: bottle.py bottle的源文件 a.py from bottle import Bottle, run mybott ...

  2. mirantis fuel 学习

    这些天看了mirantis中puppet的使用,对puppet的认识有了更深入的理解.mirantis公司的fuel主要是为了方便部署生产环境的openstack的工具.主要是在集群中自动化的安装op ...

  3. awk的使用备忘

    [转]http://www.cnblogs.com/mydomain/archive/2012/09/24/2699467.html awk引用外部变量   一.用awk 有以下几种方法去调用变量: ...

  4. C#委托的语法

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using Delegate; na ...

  5. call()和apply()的区别

    var a = function(a,b){ console.log(a+b); }, b = { c:5, d:3 }; a.call(b,1,2); a.apply(b,[1,2]); a.cal ...

  6. linux下fflush(stdin)的使用问题

    参考自linux下如何清空(刷新)stdin缓冲区 首先,fflush在C/C++/POSIX标准中只定义了处理输出流的行为,对于像stdin这种输入流,这是未定义行为undefined behavi ...

  7. ASP.NET MVC中HttpContext, HttpContextBase, HttpContextWrapper联系

    ttpContext HttpContext是最原始的ASP.NET Context. MVC的目的之一是能够单元测试.HttpContext没有base class,并且不是virtual,所以不能 ...

  8. Echarts-JAVA

    http://www.oschina.net/p/echarts-java http://my.oschina.net/flags/blog/316920

  9. [Gauss]POJ1681 Painter's Problem

    和POJ1222(分析)完全相同 题意也类似, 可以涂自己以及上下左右五个位置的颜色 问几次能全部涂色 不能输出inf 01方程组 用异或来求解就好了 ][]; // 增广矩阵 ]; // 解 ]; ...

  10. 155. Min Stack

    题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time ...