옵션 |
|
import java.util.Scanner; public class Coins { public static void main(String[] args) { Scanner scan=new Scanner(System.in); double amt; int quarter,dime,nickel,penny,totalCents; System.out.println("Please enter the amount of dollars"); amt=scan.nextDouble(); totalCents=(int)amt; totalCents= (int) (1000*amt); quarter=(int) (amt/.25); dime=(int) ((amt-(quarter*.25))/.10); nickel=(int) ((amt-(quarter*.25)-(dime*.10))/.05); penny=(int) ((amt-(quarter*.25)-(dime*.10)-(nickel*.10))/.01); System.out.println("Quarters: " + quarter); System.out.println("Dimes: " + dime); System.out.println("Nickels: " + nickel); System.out.println("Pennies: "+ penny); } } 이 소스코드를 돌려서 1.13이나 1.14 넣었을때 penny 계산이 하나적더라고요;; 수학오류를 뭘로 잡아야할까요; |