Share on Google+Share on Google+

emrit latchman
0 Answer(s)      5 years and 2 months ago
Posted in : Java Beginners

Sir,I am experiencing some problems with the output of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when the program is run.

Hardware Items Code Description Unit Price K16 Wood screws,brass,20mm,50 grams $ 7.75 D24 Wood glue,clear,1 liter,350 grams $ 5.5 M93 Sandpaper,fine grade,50 grams $ 10.25 M94 Sandpaper,fine grade,60 grams $ 14.75 B21 Claw Hammer,1500 grams $ 13.5 B35 Garden Shovel,2200 grams $ 15 A10 Garden Hose,2100 grams $ 10.25 A45 Hand Saw,1000 grams $ 12.75 C51 Garden Fork,2400 grams $ 14.5 place your order! NAME:john smith ADDRESS-1:20 rodeo street ADDRESS-2:london ADDRESS-3:england POST CODE:3587 Code:d14 Quantity: 3 Is there another Customer order?(yes/No) :yes Code:

what should really happen is that if I say yes for the dialogue the user inputs for name,address,and post code should come up followed by the code and the quantity.In other words it should process a number of orders of different names and addresses if yes is selected until the user enters no.can you help me with the code, the program is given below.Thank you!

import java.util.*; import java.text.*; import java.util.Scanner; class HardwareItems { String code; String description; double price; HardwareItems(String code,String description,double price){ this.code=code; this.description=description; this.price=price; } public String getCode(){ return code; } public String getDescription(){ return description; } public double getPrice(){ return price; }

public static void main(String []args){
    ArrayList<HardwareItems> list=new ArrayList<HardwareItems>();
    list.add(new HardwareItems("K16","Wood screws,brass,20mm,50 grams",7.75));
    list.add(new HardwareItems("D24","Wood glue,clear,1 liter,350 grams",5.50));
    list.add(new HardwareItems("M93","Sandpaper,fine grade,50 grams",10.25));
    list.add(new HardwareItems("M94","Sandpaper,fine grade,60 grams",14.75));
    list.add(new HardwareItems("B21","Claw Hammer,1500 grams",13.50));
    list.add(new HardwareItems("B35","Garden Shovel,2200 grams",15.00));
    list.add(new HardwareItems("A10","Garden Hose,2100 grams",10.25));
    list.add(new HardwareItems("A45","Hand Saw,1000 grams",12.75));
    list.add(new HardwareItems("C51","Garden Fork,2400 grams",14.50));
    DecimalFormat df=new DecimalFormat("$ ##.##");

    System.out.println("Hardware Items");
    System.out.println("Code "+"   Description "+"            Unit Price ");
    for(HardwareItems e : list){

      Scanner in=new Scanner (System .in);
    System.out.println("place your order!");
    String l=in.nextLine();
    String m=in.nextLine();
    String n=in.nextLine();
    String o=in.nextLine();
    System.out.print("POST CODE:");
    String p=in.nextLine();

    Scanner input=new Scanner(;
    System.out.print("Code:" );
        System.out.print("Quantity: ");
        int quantity=input.nextInt();
        String check="";
        System.out.print("Is there another Customer order?(yes/No) :");;
         System.out.print("Code:" );
         System.out.print("Quantity: ");


View Answers

Related Tutorials/Questions & Answers:
output  Sir,I am experiencing some problems with the output of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when
Output of flex
Output of flex  hi....... please provide the name of the output file. What is the output of flex applications? please rply ASAP........ Thanks
triangle output
triangle output  program to get the following output
output variable
output variable  if i want to print output of three variables when i wrote the code e.g SYStem.out.PRINTln(answer + answer1 + answer 2) only output of answer is getting printed out? can you help
triangle output
triangle output  program to get the following output: * *   Hi Friend, Please specify the pattern properly. Thanks
output of the program
output of the program  public static int sum(List list) { int sum = 0; for ( Iterator iter = list.iterator(); iter.hasNext(); ) { int i = ((Integer); sum += i; } return sum
What is the output if....
What is the output if....  Here is my code. what is the output...");   When we put 50 as a lower limit value, output comes: Entering... as a lower limit value, output comes: Entering the try block. Exiting the try block
What will be the Output?
What will be the Output?  int[] number = {5,3,6,10,1} int temp; for (int i=0; inumbers[j]) { temp=numbers[i]; numbers[i]=numbers[j] number[j]=temp
xml output
xml output  generate an xml output in the following format <FileCount> <DOC>AA <RTF>BB <PDF>CC <Total>DD where AA=total number of .DOC files found BB=total number of .RTF files found,etc
output error
output error  this is my program import*; public class separate { public static void main(String[] args)throws IOException...]; for (k=0;k } } if i enter "my name" as the input the output
what will the output
= (Parent) sonu;; What will be the output of above section of code
what is the output?
what is the output?  public class MyAr{ public static void main(String argv[]) { int[] i=new int[5]; System.out.println(i[5]); } }   It gives ArrayIndexOutOfBoundsException as you haven't add element to array. Correct
input output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part... used for writes byte to output stream. It implements a buffered output
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
Data input & output Stream
Data input & output Stream  Explain Data Input Stream and Data Output... stream in a machine-independent way. A data output stream lets an application write primitive Java data types to an output stream in a portable way
what is given output?
what is given output?  public class { public static void main(string argv
Output Encoding - JSP-Servlet
Output Encoding  From security vulnerability perspective, we?d like to perform output encoding of special characters (ex: < > ? ? % ; ( ) & +) on JSP while displaying pages.How can this be achieved ? Can we achieve
Input and Output package
Input and Output package  Hi guys, My professor used input and output... she used in.readint() out.writeln() commands to read input and print output. she created two new objects directly to use this statements. /* input and output
how to write code for this output?
how to write code for this output?   1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
Object Output Stream
Object Output Stream  Can anyone decode the data from a file which is written by ObjectOutputStream?? I want to know if this is a secure way to write protected data without encryption
output using SQL
output using SQL  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d
output java - Java Beginners
output java  public static int secret(int one) { int i; int...; } a. what is the output of the ff. java statement:? i. System.out.println (secret...?  Hello Are you beginner? Ok, The first Output is 125
Output of null value
(str); } } Output value Null Description:- In the given example
Error output - JSP-Servlet
Error output  Can anyone please assist me; The printed output should be: The product is 10. But instead of it I got; The product is undefined. Can anyone trace what went wrong of my code pls
input output in java
input output in java  java program using filereader and filewriter   Hi Friend, Try the following code: import*; class FileInputStreamAndFileOutputStream { public static void main(String[] args) throws
output error - JSP-Servlet
output error  /*hi friends, the given below is my servlet program error? How can i solve this problem? */ HTTP Status 500 - -------------------------------------------------------------------------------- type Exception
Handling transformation output
Handling transformation output       Handling transformation output After passing xml and xsl sheets , we need to handle output ,after transformation
Input And Output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part of for writes byte to output stream. It implements a buffered output stream
Creating custom output using XMLUnit - MatchTracker duplicates the output data
Creating custom output using XMLUnit - MatchTracker duplicates the output data  how to create a custom output using xmlunit, I have tried it and used... in input xml and I am having duplicate data in output
XSLT Output Types
; } Output Types The xsl:output element lets you specify how to generate result output. Although it is not required to specify the type of output but an XSLT... of the output element.  The xsl:output element is a top-level element
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null