Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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

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


    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,082
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •