HW3.7

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的更多相关文章
- HW3 纠结的心得
改好的controller //yuec2 Yue Cheng package hw3; import java.io.File; import java.text.DecimalFormat; im ...
- 基于卷积神经网络的面部表情识别(Pytorch实现)----台大李宏毅机器学习作业3(HW3)
一.项目说明 给定数据集train.csv,要求使用卷积神经网络CNN,根据每个样本的面部图片判断出其表情.在本项目中,表情共分7类,分别为:(0)生气,(1)厌恶,(2)恐惧,(3)高兴,(4)难过 ...
- Software Testing hw3
(a):可绘制出如下图所示的流程图 (b):对于测试用例t1=(n=3)和t2=(n=5),MAXPRIMES = 4时,t1不能检查出错误,而t2则会发生数组越界错. (c):要使测试路径不通过wh ...
- HW3.29
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW3.28
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW3.27
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW3.26
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW3.25
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW3.24
public class Solution { public static void main(String[] args) { int number = (int)(Math.random() * ...
- HW3.23
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- 关于 js 2个数组取差集怎么取
关于 js 2个数组取差集怎么取? 例如求var arr1 = [1]; var arr2 = [1,2];的差集方法一: Array.prototype.diff = function(a) { r ...
- noj [1475] Bachelor (找1的个数)
http://ac.nbutoj.com/Problem/view.xhtml?id=1475 [1475] Bachelor 时间限制: 1000 ms 内存限制: 65535 K 问题描述 炎热的 ...
- caffe之(五)loss层
在caffe中,网络的结构由prototxt文件中给出,由一些列的Layer(层)组成,常用的层如:数据加载层.卷积操作层.pooling层.非线性变换层.内积运算层.归一化层.损失计算层等:本篇主要 ...
- Automotive Security的一些资料和心得(6):AUTOSAR
1.1 Introduction AUTOSAR(汽车开放系统架构)是一个开放的,标准化的汽车软件架构,由汽车制造商,供应商和开发工具共同开发.它联合了汽车OEM ,供应商和开发工具供应商,其目标是创 ...
- 在Unity中高效工作(下)
原地址:http://www.unity蛮牛.com/thread-20005-1-1.html Tips for Creating Better Games and Working More Eff ...
- JDBC MySQL字段类型为datetime的数据取出(util.Date)
使用ResultSet的getTimestamp方法获取java.util.Date型数据 java.util.Date time = rs.getTimestamp("time" ...
- cocos2d-html5 Layer 和 Scene 创建模式
var myLayer = cc.Layer.extend({ init:function() {//2 界面 var bRet = false; if (this._super()) { bRet ...
- 在C++中子类继承和调用父类的构造函数方法
构造方法用来初始化类的对象,与父类的其它成员不同,它不能被子类继承(子类可以继承父类所有的成员变量和成员方法,但不继承父类的构造方法).因此,在创建子类对象时,为了初始化从父类继承来的数据成员,系统需 ...
- .net 破解的几个常用工具
在.net 破解中我们经常会提到 Reflector\SimpleAssemblyExplorer和CFF Explore这几个工具. 我们以一个简单的确Windows Form程序为例来说说他们怎么 ...
- BZOJ_1096_[ZJOI2007]_仓库建设_(斜率优化动态规划+单调队列+特殊的前缀和技巧)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1096 有\(n\)个工厂,给出第\(i\)个工厂的到1号工厂的距离\(x[i]\),货物数量\ ...