...

View Full Version : Urgent Help needed with implement a method in a loop



Buffalo_Soldier
01-10-2012, 07:56 AM
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

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



public 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



//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

Philip M
01-10-2012, 08:15 AM
This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!


It is your responsibility to die() if necessary….. - PHP Manual



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum