Home Answers Viewqa Java-Beginners write a program to store information of 50 products

 
 


Amit
write a program to store information of 50 products
1 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners

write a program to store information of 50 products(code, quantity and price). Calculate the total cost (quantity*price) of each product and print the information.

View Answers

March 26, 2011 at 11:52 AM


import java.util.*;

class ShowData{
        String code;
        int quantity;
        double price;
        ShowData(String code,int quantity,double price){
        this.code=code;
        this.quantity=quantity;
        this.price=price;
        }
        public void setCode(String code){
                this.code = code;
        }
        public String getCode() {
                return code;
        }
        public void setQuantity(int quantity) {
                this.quantity = quantity;
        }
        public int getQuantity(){
                return quantity;
        }
        public void setPrice(double price) {
                this.price = price;
        }
        public double getPrice(){
                return price;
        }
       }
public class ArrayListEx{
         public static void main(String[] args){
             Scanner input=new Scanner(System.in);
               ArrayList<ShowData> list=new ArrayList<ShowData>();
               for(int i=0;i<50;i++){
                  System.out.print("Enter code: ");
                  String code=input.next();

                  System.out.print("Enter Quantity: ");
                  int quantity=input.nextInt();

                  System.out.print("Enter Price: ");
                  double price=input.nextDouble();
               list.add(new ShowData(code,quantity,price));
               }
               for(ShowData data: list){
                   double cost=(data.getQuantity())*(data.getPrice());
               System.out.println(data.getCode()+"\t "+data.getQuantity()+"\t "+data.getPrice()+"\t "+cost);
               }
         }
}









Related Pages:
PLEASE Help me write a Java program which will store, manipulate, and print student registration information.
PLEASE Help me write a Java program which will store, manipulate, and print..., ADDRESS AND ADMISSIONS CLASS PLEASE HELP!!! Write a Java program which will store, manipulate, and print student registration information. As part
store
store  hi i want store some information in my program and use them in other method. what shoud i do
Write a program to get student details and store in a database
Write a program to get student details and store in a database  Write a program to get student details and store in a database
QUE 50 ...please show output also...
QUE 50 ...please show output also...  Q1. Write a program to find... line argument. Q2. Write a program that prints the prime no between 0 and 100. Q3. Write a program to determine grade for given marks Marks
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  Write program which accepts five students id,name,age,department,courses, taken and its grade. a. calculate its GPA . display all student information in ascending order
information
information  hello sir i installed java1.5 s/w but java editor not displaying. i wants to create a desktop icon for this application.without notepad i wants to write code in code window like c,cpp.plz help me. replay
Write a program named InternetCharge_YourLastName that do the following:
Write a program named InternetCharge_YourLastName that do the following: ... per month unlimited access is provided. Write a program named InternetCharge.... Additional hours are $1.00 per hour. Package B: For $24.95 per month 50 hours
write program - Java Beginners
write program  write a java program that will read the values of matrix A and B give its multiplication in matrix C  Hi friend, Code...]); } System.out.println(); } } } For more information on java visit to : http
how to write store procedure in sql
how to write store procedure in sql  How to write a store procedure in SQL Server
Jdbc Program for building Student Information Database - JDBC
Jdbc Program for building Student Information Database  import...;); b7.addActionListener(this); tf1=new TextField(50); tf1.setBackground...); tf3=new TextField(50); tf3.setBackground(Color.yellow); tf4=new
check box realtive information in page store in database
check box realtive information in page store in database  check box relative information in page store in database  hiiiiiiiii, Que I create a checkbox in html and when i click on my check box realtive information
write a program
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java
Shopping Cart Products
Know To Sell The Right Products On E-Commerce Shopping Cart E-commerce... as this is the fastest way of shopping and shipping products to customers. Many online... for this is that there are millions of websites selling countless products, which rouses the question
write program have product - using loops
write program have product - using loops  Write a program for a grocery that reads products data and determine and display the product that has...), name (String) and price (double). Your program should continue reading new
iPhone Application Store Submission and Acceptance Process
distributed through means other than its Application Store. iPhone Developer Program... iPhone Application Store Submission and Acceptance Process... App Store or Seller's store. While the first two steps have been detailed
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
How to create dynamic buttons for adding products on a cart.
How to create dynamic buttons for adding products on a cart.  Hi. I... dynamic products from a database, and i would like to know how to group this products...="50" value="#{searchEngine.searchWord}"/> <h
Write a program to display grade message according to the marks
Write a program to display grade message according to the marks  pls give d answer how to Write a program to display grade message according to the marks     Write a program to display grade message according
write a java program
write a java program  write a program to print '*' in a circular form
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
Write a java application program........?
Write a java application program........?  Welcome every One : I have Q in Java? Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers
write a program to print
write a program to print   write a program to print following 1 2 3 4 5 4 3 2 1 1 2 3 4 4 3 2 1 1 2 3 3 2 1 1 2 2 1 1 1
Write to a file
; the BufferedOutputStream class that store the data in an internal buffer and lets you write... Write to a file   ...;} } Output of the Program: C:\nisha>javac WriteFilter.java
Write a program in java...
Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two... to enter an integer number. Write a program in java to find the factorial
how to write this program
how to write this program  Write a program in java which calculates... or numerical grade. You will be submitting TWO versions of this program. Write one...?¢s GPA. This program should take a studentââ?¬â?¢s First Name, Last Name a GPA
write a program - Java Beginners
write a program  1. write a program that reads a string composed of 6 words then generate and print a word composed of the first letters of the 6 words.  Hi friend, Code to solve the problem : class FirstLetter
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  How do I write a program in Java, have the program display a message with your name in it and a number (Hello john Smith!1) The number must increment from zero to nine, or decrement fron nine to zero. You
help to load information in init of application - Struts
u tell me in the whole struts2 application, where should i write the code to store that information for further use. Thanking u...help to load information in init of application  Thanks for ur
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program... the Examples of How to write to File in Java Program: WriteToFileExample.java import... of characters and the BufferedWriter is used for store the characters in a buffer
write java code discount bookstore - Java Beginners
with special discounts, while others are sold at normal price. Write a program which...write java code discount bookstore  The question Cik Mat operates... transaction. However, the program will be better if a customer can buy and pay
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill will be formatted as the example on the next page. The following information
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill will be formatted as the example on the next page. The following information
write a program in java.
write a program in java.  arrange the natural n umber in 5x5 matrix as 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 i at centerd position and remaining arrange in anticlockwise direction.  
write following program
write following program  Q1 What is the difference between single...-threading. Explain with examples Q2 Write a java applet that takes your name through a parameter from the HTML file and displays it Q3 Write a short note
how to read the values for text and csv files and store those values into database in multiple rows..means one value for one row
how to read the values for text and csv files and store those values... a program by using servlets.. the program is like this i upload a text and csv... or .txt) file and get the values from that file and store them into database
Write an event driven program to perform the arithmetic operations as shown in the interface
Write an event driven program to perform the arithmetic operations as shown... the java programming code for that question. my question is here: Q. Write an event driven program to perform the arithmetic operations as shown
Write a program to print using for loop
Write a program to print using for loop  Write a program to print using for loop * * * *  
How to write calculator in J2ME program?
How to write calculator in J2ME program?  How to write calculator in J2ME program
how to write servlet program in eclipse?
how to write servlet program in eclipse?  how to write servlet program in eclipse
J2ME Record Store Example
J2ME Record Store Example       In this Midlet, we are going to read string data and write... is the javax.microedition.rms. In our program we have used a byte[] to read the data
Simple java program
confused on how to write this program it would be a great help i could be helped... that program. plz do help me out here. Part I Write a program... marks up the prices of its items by 25%. Write a Java program that declares
how to write this program? - Java Beginners
how to write this program?  (game:scissor,rock ,paper) A program that plays the sciccor-rock-paper game.Revise the program to let the user continuously play until either the user or the computer wins more than 4 times
Java store objects in File
Java store objects in File In this section, you will learn how to use the ObjectOutputStream and ObjectInputStream to write and read serialized object... or java.io.Externalizable interface can only be read from streams and write to streams. In the given
write a program to create a user defined
write a program to create a user defined   plz send me code   Hi Friend, Please specify what do you want to create? Thanks
Java Program - Java Beginners
Java Program  how will write Java programs using if-else, if-else...){ System.out.println("Greater than 100"); } else if(i > 50){ System.out.println("Greater than 50"); } else{ System.out.println("Less than 50"); } } } 3) Switch
Sales Letters Write Services
presentation of products or services. We have an excellent track record to generate... of business and copywriters with good experience in advertising, we write... target audience is and give them information about the benefits they will get
to write a program to display the employee details..
to write a program to display the employee details..  To dipslay... running this program the new window has to be opened asking us to enter all...   not this one actually i wnat a very small program that displays all
Sending and receiving information to the UDP Client in Java
Sending and receiving information to the UDP Client in Java... will provide send and receive information by the UDP client in Java. UDP client sends information or messages to UDP server and it collects some messages from
Java Write To File Binary
process to execute a java program write simply on command prompt as : javac... with containing the text that you are trying to write into the file by java program...Java Write To File Binary In this tutorial you will learn how to write
Write Text into File
Write Text into File      ... this example we are initialize string to write into file. We are creating file in which we are writing string by use of write() method. We need  java.io.

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.