Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


Hi how could I modify this program so that if I say yes for the dialog the following prompt would be displayed for the user to enter the information and would stop if no is selected.As the program is now if I say yes only the user input for the code and quantity is displayed,thank you.

address 1: address 2: address 3: post code: code: quantity:

the is the program

mport java.util.*; import java.text.*; import java.util.Scanner; class HardwareItems { String code; String description; double price,total; double vat=0.2;
int weight,quantity,shipping, cost;

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();
    System.out.println("Code "+"   Description "+"            Unit Price ");
    for(HardwareItems e : list){
            System.out.println(e.getCode()+"\t"+e.getDescription()+"\t"+df.format(e.getPrice()));
            }


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

    Scanner input=new Scanner(System.in);
    System.out.print("Code:" );
        String code=input.next();
        System.out.print("Quantity: ");
        int quantity=input.nextInt();
        String check="";
          while(!check.equals("no")){
        System.out.print("Is there another Customer order?(yes/No) :");
         check=input.next();
        if(check.equals("yes")){
         System.out.print("Code:" );
            code=input.next();
         System.out.print("Quantity: ");
            quantity=input.nextInt();
        }
        else{
            break;
            }
           }
        }
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
modify program
modify program  Hi how could I modify this program so that if I say... the information and would stop if no is selected.As the program is now if I say.... address 1: address 2: address 3: post code: code: quantity: the is the program
Is it modify Object data? Generally Object data can't modify............but in this program it modifies.......... Why?
Is it modify Object data? Generally Object data can't modify............but in this program it modifies.......... Why?   import java.io.*; public class Conversions { public static void main(String args[]) throws Exception
Advertisements
Modify the sales tax program to accept an arbitrary number of prices, total them, calculate the sales tax and print the total amount.
Modify the sales tax program to accept an arbitrary number of prices, total them, calculate the sales tax and print the total amount.  Modify the sales tax program to accept an arbitrary number of prices, total them, calculate
how to modify QuestionServlet.java page?
how to modify QuestionServlet.java page?  Dear frnds, how to modify existing QuestionServlet. java file
date_modify
date_modify() in PHP date_modify or DateTime::modify function modifies... by strtotime(). It returns the modify date time. Description public DateTime DateTime::modify ( string $modify ) DateTime date_modify ( DateTime $object
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
Modify Data Type with ALTER Command
Modify Data Type with ALTER Command  Is it possible to modify... EmpName INT; Is it possible to modify the above table like... the following query: ALTER TABLE Emp MODIFY EmpName int(255
how to modify content of XML file
how to modify content of XML file  hi, I want to modify content of a xml file.There are two tags of similar name say <ContentName>C:\Myinfo... modify....!!! How do i do it??can somebody give me a sample code
can modify this application connection with database
can modify this application connection with database   hi i'm want to say who thank java master or java professional help me convert Java applet... modify connection with database ? import javax.swing.*; import java.applet.
How can i modify my account in roseindia
How can i modify my account in roseindia  Presently am not using my gmail id. I have to modify my roseindia account. Please send the answer to following mail id
Java-Xml -Modify and Update Node - Java Beginners
Java-Xml -Modify and Update Node   test_final_1 2009-025T13:23:45 B2B and using the following code... import javax.xml.parsers....(); } } I want to modify the values of and in the above xml posted and update
Java--Xml Modify Node Value - Java Beginners
Java--Xml Modify Node Value  I have the following xml. test_final_1 2009-025T13:23:45 B2B . I want to retrieve the values of ,,and through NodeList. I wrote the follwoing code. package xml_handson; import
please modify this so that it can work better - Swing AWT
please modify this so that it can work better   this program is about opening a savings account, i need any one to modify it and add new features to it to make i more better.no database is needed. the codes are; // class
modify this so that i can work better - Swing AWT
modify this so that i can work better  this program is about opening a savings account, i need any one to modify it and add new features to it to make i more better. the codes are; //OpenSavingsAccount1.java import
Please help me to modify my java code from php code
Modify Java code from PHP Code  i want to covert this php code int java/JSP. if (isset($_POST['orders'])) { $orders = explode('&', $_POST['orders']); $array = array(); foreach($orders as $item) { $item
Need someone to check and modify my simple code - Java Beginners
Need someone to check and modify my simple code   How to write a class that contains Variables that hold hourly rate of pay, number of hours worked. Display gross pay, withholding tax, which is 15% and net pay. I have tried
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert this php code int java/JSP . if (isset($_POST['orders'])) { $orders = explode('&', $_POST['orders']); $array = array(); foreach($orders as $item
program
program  any program of hotel or school management
program
program  write a program different between to dates in terms of days in java
program
program  write a html program in show table and this word in box
program
program  write a javascript program to create a application form with validation
program
program  program of jdbc using ms access for creating table
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link: Java Threads Thanks
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
Advertisements
 

 

 

DMCA.com