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




Have Programming Question? Ask it here!
 
 
 


emrit latchman
modify program
0 Answer(s)      2 years and 2 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
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 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
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
program
program  any program of hotel or school management
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
program
program  program of jdbc using ms access for creating table
program
program  write a javascript program to create a application form with validation
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
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   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
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  explanation of program on extending thread class   Hi Friend, Please go through the following link: Java Threads Thanks
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  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 a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = ‚??Tommy‚?? age=‚??23‚?? and call this constructor
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
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
program calculateCylinderVolume
program calculateCylinderVolume  program calculateCylinderVolume
java program for
java program for   java program for printing documents,images and cards
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
string program
string program  write a program to print the pattern p r o program r a m
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
program for factorial
program for factorial  how to set size of buttons on frame
program for factorial
program for factorial  how to set size of buttons on frame
 

 

 

DMCA.com