Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-10-2012, 08:29 AM   PM User | #1
Buffalo_Soldier
New to the CF scene

 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Buffalo_Soldier is an unknown quantity at this point
Urgent Help needed with implement a method in a loop

Friends i'm in a dire situation only have wednesday to submit ..so heres the problem....i have a course work assigment where i have to hardwire Hardware items and their item codes description and prices and ask the user to input their name address the itemCode and quantity nad then creat an invoice which looks like this

Quote:
HARDWARE ITEMS
CODE DESCRIPTION UNIT PRICE
K16 Wood screws, brass, 20mm, pack of 50 $ 7.75
D24 Wood glue, clear, 1 litre $ 5.50
M93 Sandpaper, medium grade, 100 sheets $10.25
M94 Sandpaper, fine grade, 100 sheets $14.75

PLACE YOUR ORDER!
NAME: Bill Silic
ADDRESS-1: Apt 23
ADDRESS-2: Building 8
ADDRESS-3: Winchester
POST CODE: 89763
ENTER CODE (XX to Stop):
CODE: D24
QUANTITY: 2
CODE: K16
QUANTITY: 1
CODE:XX


INVOICE FOR ORDER
Bill Silic
Apt 23
Building 8
Winchester POST CODE: 89763
D24 Wood glue, clear, 1 litre 2 @ $ 5.50 $ 11.00
K16 Wood screws, brass, 20mm, pack of 50 1 @ $ 7.75 $ 7.75
TOTAL: $ 18.75
Shipping: 2 items @ 1.00 2.00
TOTAL INCL. SHIPPING: 20.75
VAT at 20% 4.15
TOTAL TO PAY: 24.90
I HAVE ALREADY COMPLETED THIS BY MYSELF AND GOT IT WORKING WITH NO PROBLEM ..But my problem is that the teacher wants us to TEST FOR NULL ENTRY meaning if the user enters the wrong Itemcode or no ItemCode at all and give an sensible output for that case ..... she wants us to put it in a method after main and then call it in main using a do while loop so my method looks something like this


Code:

p
Code:
ublic static boolean isSomethingCorrect(String itemCode){
			if(itemCode.equals("")||itemCode.equals(null)){
				System.out.println("A sensible output");
				return true;
			}//close if
			return false;
		}
		
		
  }
// and i have to implement it where i ask the user for input using a Do while loop in this area


Code:

Code:
 //a do while loop to test null code entry
	                  do{
	                       System.out.println("Please select a code from the list");
	                       String itemCode= br.readLine();
						  
					   
						
	                       System.out.println("Please enter quantity of items " +itemCode);
	                       String itemQuantity= br.readLine();
	                       int quantity= Integer.parseInt(itemQuantity);
// I Will be forever grateful for any help on this program because i have tryed for hours upon hours and i just cant get it and i need to submit the day after tomorrow
Buffalo_Soldier is offline   Reply With Quote
Reply

Bookmarks

Tags
code, do-while, loop

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:32 AM.