21 February 2005 - java_dev (original) (raw)

Java developers

February 21st, 2005

| | 11:23 am - partypatrol - i'm new to java and i need help. This may be a simple program to you but I need help creating a program that gives change... this is the directions:Implement a program that directs a cashier how to give change. The program has two inputs: the amount due and the amount recieved from the customer. Compute the difference, and compute the dollars, quarters, dimes, nickels, and pennies that the customer should recieve in return.First transform the difference into an integer blance, denominated in pennies. Then compute the whole dollar amount. Subtract it from the balance. Compute the number of quarters needed. Repeat for dimes and nickels. Display the remianing pennies.The class I called was Cashier... and this is what I have.public class Cashierpublic Cashier(){pennies = 1;nickels = 5;dimes = 10;quarters = 25;dollars = 100;}public void setAmountDue(double anAmountDue){amountDue = anAmountDue;}public void receive(double amountReceived){received = amountReceived}---From there I don't know what to do with the calculations because I know logically how to do it. Say the amount was 5.50andthepersongavea5.50 and the person gave a 5.50andthepersongavea10, so 10-5.50, but I don't know how to do that in the program. | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

09:05 pm - kritof - Java IO help!!!!! I have three assignments for class: 1. use a stack with exceptions to solve the problem of balanced parentheses, brackets, and braces; 2. use the same definition to solve the problem of evaluating a postfix arithmetic expression; 3. use the same definition to solve the problem of converting an infix arithmetic expression to its equivalent in postfix form.There are some basics my teacher seemed to have left out. He explained the BufferedReader etc for input, but I cannot figure out how to take a line of input from the keyboard and push each individual character onto a stack. Is there a simple way of doing this that I have missed? It's difficult to go much further with my programs without knowing this. Thanks for any and all help!!!!
09:24 pm - chemicalbeats Hey guys, just a fairly quick question - don't need you to actually do my coursework for me ;)I have a class that needs to store a load of objects - an example would be a class called CustomerStore, that looks after multiple Customer objects.The customer objects are all refered to by other parts of the program by a customer ID - which is mostly contiguous (1,2,3,4,5 - n) etc.Main thoughts were storing in a hash tableOr as the numbers were mostly contiguous store in a vector list with a seperate vector list or array of customerIDs to point at the relevant objects. The only problem I have is when it comes to deleting objects. Anyone got any ideas on how to handle this gracefully? The IDs for other objects need to stay the same and new objects can't resuse them.I apologise if the above doesn't make sense/is really blindingly obvious...Cheers