Results 1 to 2 of 2
Thread: Some java assistance
 04012012, 10:24 AM #1Member
 Join Date
 Apr 2012
 Posts
 1
 Rep Power
 0
Some java assistance
Evening friends. I've been in this Java 1 class for a few weeks. Prior to this I knew nothing of java and my logic and math intelligence is quite low. So I've come here for some assistance. Our current assignment is this:
Write an application that prompts for and reads a double value representing a monetary amount. Then determine the fewest number of each bill and coin needed to represent the amount, starting with the highest (assume that a twentydollar bill is the maximum size needed). For example, if the value entered is 57.63 then the program should print the equivalent amount as:
2 twenty dollar bills
1 ten dollar bills
1 five dollar bills
2 one dollar bills
2 quarters
1 dimes
0 nickels
3 pennies
I will paste my code of what I have so far, I am using Eclipse.
package com.homework.assignment2;
import java.util.Scanner;
public class MoneyApp {
public static void main(String[] args) {
//Prompt for an amount between 1 & 1000
System.out.println("Enter in a dollar amount between $1.00 & $5,000.00:");
//get amount entered from user
Scanner sc = new Scanner(System.in);
double dollar = sc.nextDouble();
System.out.println("You typed = " + dollar + " thank you ");
//let's say I type in 3,333.99
//output amount
System.out.println("You typed =" + amount + "good job");
///Dollar Section
//Step 1
//take (original)3333.99 divide by 20
//answer is 166
//Step 2  to find out how much remains, take dollar only answer times 20
//166 x 20 = 3320
//take 3333  3320 to find out remaining amount. This leaves 13 dollars
//to find out how many tens, take 13 / 10, which gives 1.3
//to find out how much we have remaining, take 10 x 1
//take 13  10 = 3.
//take the remaining 3 divide 5, which equals 0 fives.
//0 x 5 = 0
//3  0 = 3
//3 / 1 = 3, number of 1's given.

//166 x 20 = 3320
//1 x 10 = 10
// 0 x 5 = 0
// 3 x 1 = 3
//total = 3333 (total)
///Change Section
//take 'original' which is 3333.99 subtract 3333.00 from it to equal .99 remaining
//remaining amount is still 3, next number is 3 divided by 1
}
}
**As you can see I spent quite some time just making comments to do the math in my head and get it on paper. I'm not quite sure how to turn all of this into workable code. Any assistance would be great. Thank you!
 04012012, 12:37 PM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,299
 Blog Entries
 7
 Rep Power
 24
Similar Threads

assistance w/ java programming assignment
By clemsontigers in forum New To JavaReplies: 4Last Post: 04072011, 08:07 PM 
Java Generics assistance and confusion
By sideswipe091976 in forum Advanced JavaReplies: 9Last Post: 03302011, 08:24 AM 
Learning Generics in Java. Need Assistance
By codex in forum New To JavaReplies: 1Last Post: 03252011, 06:00 PM 
Looking for assistance
By s_dawg101 in forum New To JavaReplies: 32Last Post: 11042009, 03:49 AM 
Java N00B  Remote Assistance Invitations
By victimist in forum Java AppletsReplies: 6Last Post: 10252008, 01:30 AM
Bookmarks