• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with my loop, array and PrintWriter  RSS feed

 
Connor Palazzo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm making a program that saves the customers name address and email.
I'll make it short and post this:
The sales associate should now be allowed to enter multiple products to be displayed on the total bill.
Modify your program to include a loop that will ask the sales associate the products the customer is purchasing and the quantity. This loop should continue until the sales associate decides to not enter any more products.
Store this information in an array. Display the total bill to your sales associate with all of the products entered. (You can use an array or an arrayList) Hint*You will need to loop through the array or arrayList to display the products, quantity and price in the totalBill.
Modify your program to include a loop so that the user is continually asked the main menu until they have selected option number 4 to Quit the program.
The user should be continually asked to go to the main menu until they have selected option number 4 to quit the program.

Your option menu will now look like this:
1. Enter customer information
2. Price Lookup
3. Display Total Bill
4. Quit

Your total bill should still look like this:


John Doe
2206 Anywhere Street
Anywhere, TX. 88888
john.doe@anywhere.com

Product Purchased Quantity Total Cost

Shoes 2 $100.00
Shorts 1 $75.00

Tax (@8%): $14.00
Total Cost: $189.00


Here's my code:
I need to loop my array/Array List so I can display the total cost.
Any help will be appreciated.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Connor Palazzo wrote:Any help will be appreciated.

OK:

1. Please UseCodeTags (←click). I've added them for you this time; see how much better it looks? I suggest you read the link carefully.

2. That is a fabulous amount of code to put in one place, let alone in main(). Have you learnt how to write methods yet? Because if so, I suggest you think how you might break it up a bit, because if you continue in this style your problems will only increase.

3. Your indenting is very bad, which makes it doubly difficult to work out what's going on.

4. You haven't actually told us what's wrong with what you've written; however, I don't see anywhere that you're adding the entered product and quantity to a List inside your do....while(repeat=='y') loop.

5. Your loop is do....while(repeat=='y'), but inside it you ask:
"Would you like to add another product? [Y/N]".

My advice: StopCoding (←click) - read the link thoroughly, and come back if anything in it doesn't make sense.

HIH

Winston
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!