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 11.56: ");
         double amount = input.nextDouble();
         int remainingAmount = (int)(amount * 100);
         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");
         if(numberOfOneDollars != 0)
             System.out.println("\t" + numberOfOneDollars + " dollars");
         if(numberOfQuarters != 0)
             System.out.println("\t" + numberOfQuarters + " quarters");
         if(numberOfDimes != 0)
             System.out.println("\t" + numberOfDimes + " dimes");
         if(numberOfNickels != 0)
             System.out.println("\t" + numberOfNickels + " nickels");
         if(numberOfPennis != 0)
             System.out.println("\t" + numberOfPennis + " pennis");
     }
 }

HW3.7的更多相关文章

  1. HW3 纠结的心得

    改好的controller //yuec2 Yue Cheng package hw3; import java.io.File; import java.text.DecimalFormat; im ...

  2. 基于卷积神经网络的面部表情识别(Pytorch实现)----台大李宏毅机器学习作业3(HW3)

    一.项目说明 给定数据集train.csv,要求使用卷积神经网络CNN,根据每个样本的面部图片判断出其表情.在本项目中,表情共分7类,分别为:(0)生气,(1)厌恶,(2)恐惧,(3)高兴,(4)难过 ...

  3. Software Testing hw3

    (a):可绘制出如下图所示的流程图 (b):对于测试用例t1=(n=3)和t2=(n=5),MAXPRIMES = 4时,t1不能检查出错误,而t2则会发生数组越界错. (c):要使测试路径不通过wh ...

  4. HW3.29

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

  5. HW3.28

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

  6. HW3.27

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

  7. HW3.26

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

  8. HW3.25

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

  9. HW3.24

    public class Solution { public static void main(String[] args) { int number = (int)(Math.random() * ...

  10. HW3.23

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

随机推荐

  1. Django环境搭建和项目创建

    1.下载安装python 2.打开shell(windows下cmd),安装虚拟环境工具:  "pip install virtualenv".(可以通过“python -m pi ...

  2. Xcode常见错误以及解决方案

    一.Undefined symbols for architecture x86_64: Xcode升级到5.1 新特性之一就是默认让所有App都通过64位编译器编译.原来在Xcode5.0.x的时候 ...

  3. css 垂直同步的几种方式

    第一种: 利用 display:table 和 display:table-cell 的方式 这种方式就好像将table布局搬过来一样,相信大家对table的td还是有印象的,它的内容是可以设置垂直居 ...

  4. oracle dblink 配置两个ip

    create database link test_link connect to xx identified by xx using '(DESCRIPTION = (ADDRESS_LIST = ...

  5. HDU 2844 Coins(多重背包)

    点我看题目 题意 :Whuacmers有n种硬币,分别是面值为A1,A2,.....,An,每一种面值的硬币的数量分别是C1,C2,......,Cn,Whuacmers想买钱包,但是想给人家刚好的钱 ...

  6. 这个帖子要收藏,以后用得着--python 实时获取子进程输出

    在论坛上找到方法了,http://bbs.csdn.net/topics/340234292 http://blog.csdn.net/junshao90/article/details/821575 ...

  7. Cannot generate SSPI context---MS SQL ERROR

    http://www.cnblogs.com/newr2006/archive/2011/08/25/2153253.html Additional error information from SQ ...

  8. 【Linux安全】chattr命令锁定账户敏感文件

    有时候你发现用root权限都不能修改某个文件,大部分原因是曾经用chattr命令锁定该文件了.chattr命令的作用很大,其中一些功能是由Linux内核版本来支持的,不过现在生产绝大部分跑的linux ...

  9. Android imageview显示圆形图片

    需要ImageView显示圆形图片做法如下 public static Bitmap toRoundCorner(Bitmap bitmap, float ratio) { System.out.pr ...

  10. Python sh库学习 上篇

    官方文档有句话"allows you to call any program",并且:helps you write shell scripts in Python by givi ...