Computer Science Canada

Quick Beginner Java Problem

Author:  Jorrdddo [ Sun Nov 25, 2012 6:30 pm ]
Post subject:  Quick Beginner Java Problem

Hey guys, I'm having problems with a Java program but I have no idea where to begin to write it.
I have to create a program for an imaginary hardware store.. this program will be used as a CHECK OUT. (after shopping)

What my program should do:
User will enter their name, then program will prompt them to enter Prices of "purchases they have made"

--------------------------------------------------------------------------------------------------------
- Get users name
- Program must keep a running total of prices entered.
- Each price entered must be echoed back to user after they enter it (when user enters price, program must say "THAT ITEM WAS $ ______, your running total is now $_______"
- If incorrect price is entered, user can press 0 to remove last entry and code will adjust running total. The price will also have to be removed from the array.
^ - If incorrect price is entered, program must recognize this ("ZERO ENTERED: removing last item $________. Your running total is now $_________"
- When user enters -1 to indicate they are done, program will total up purchases and indicate:
List out the price of each item purchased
SubTotal purchases before tax
HST owing
Grand total of purchases plux taxes

- HST PAYABLE MUST BE CALCULATED IN A SEPERATE METHOD.. You will pass into the method the sub-total of the purchases before tax, and the method will return the amount of HST owing.


An example of the program

Hi Welcome to the Checkout.. What is your name?

User enters name

OK, name, enter the price of each purchase in dollars and cents and then push the ENTER key.
If you make a mistake when you enter a price, enter a zero for the next entry and the last price you entered will be subtracted from your running total.
When youve entered all of your prices, enter a -1 to indicate that you've finished your entries. I'll then calculate what your total owing is.

User enters data

End




THANK YOU FOR TAKING THE TIME TO READ THIS. I would appreciate a quick response.. You don't have to type out a full working program, I just want to be able to know how to do these things in Java and this example is perfect.
Thanks Smile

Author:  Insectoid [ Sun Nov 25, 2012 6:34 pm ]
Post subject:  RE:Quick Beginner Java Problem

What's the first thing the program is supposed to do? Maybe that's where you should start.

Author:  Panphobia [ Sun Nov 25, 2012 7:06 pm ]
Post subject:  RE:Quick Beginner Java Problem

I am guessing your teacher wants you to use the swing class right? So just use JOptionPane to get the inputs parse the shopping list entries as doubles, then add them together, this will be your subtotal, then add the HST and there.


: