write a program to store information of 50 products

write a program to store information of 50 products

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 Tutorials/Questions & Answers:
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
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
Advertisements
write a program
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java
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
how to write store procedure in sql
how to write store procedure in sql  How to write a store procedure in SQL Server
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
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 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
write the java program?
write the java program?  1 11 121 1331 14641 15101051
write the java program?
write the java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
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 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
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
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
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
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?ADS_TO_REPLACE_1 Thanks
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
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
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
how to write the program - Java Beginners
how to write the program  WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects Lang Hindi History Geography Math Phy Chem. Bio Eve CSTA Also has a back up
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
write a program in C to print following triangles on the screen
write a program in C to print following triangles on the screen  write a program in C to print following triangles on the screen
write a program to demonstrate wrapper class and its methods......
write a program to demonstrate wrapper class and its methods......  write a program to demonstrate wrapper class and its methods
write a program to use for loop print **********========== in c language
write a program to use for loop print **********========== in c language  write a program to use for loop print **========== in c language
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
how to write a program to search a record using mvc2
how to write a program to search a record using mvc2   how can we write a code to search a record in table by using java bean as model, servlet as contoller and jsp as view
Write a program that takes the marks of user as input
Write a program that takes the marks of user as input  Write a program that takes the marks of user as input. If marks are greater then 60... not understand how to write a program like this and thank you
write a java program to solve the infix expression
write a java program to solve the infix expression  ==>> solve the below expression using java program: 2+5*2-5+6/2 using stack operations or any other process in java
write a program for complete JDBC based application
write a program for complete JDBC based application   thank you sir giving answer for my question. my another question is: Write a complete JDBC... and the program should have the facilities of Adding, Modifying, Viewing and Deleting
Help me to write this simple java frame program
Help me to write this simple java frame program   I want to write a Java program for.... To create a frame with 4 text fields;name,street,city and pin;with suitable labels. Also add a button "OK". After enter values
Write a java program that prints out the following menu???
Write a java program that prints out the following menu???  Write a java program that prints out the following menu. Auser can interact with the menu using numbers (1,2,3,4,5,6). The menu will be printed again if the user enters
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
how do i write a java program for this??
how do i write a java program for this??  â??Ask the user if they have a dog. If â??yesâ??, ask the user how old is and compute the dogâ??s age... in your program
write a java program that implements the following classes:
write a java program that implements the following classes:  write a java program that implements the following classes: A) a) Point in the Cartesian coordinate system. b) Circle with a given center and radius c) Cylinder
How to write a program count total prices
How to write a program count total prices  Hi. all I've got a assignment to write a program that count total prices of 8 costumers. class PriceCalculator{ public void method(double quantity) { double result
Please write code for this program in java and Explain it ? pl'sssssssss
Please write code for this program in java and Explain it ? pl'sssssssss ... that were ever alive at one time. Write a method to compute this, given the above array of 2n integers. Write one of the following methods: C/C++: int
How to write a program count total prices
How to write a program count total prices  Hi. all I've got a assignment to write a program that count total prices of 8 costumers. First class class PriceCalculator {print("code sample"); public void method(double quantity
store
store  hi i want store some information in my program and use them in other method. what shoud i do
How do I write a program to manage an employee's business and personal contacts?
How do I write a program to manage an employee's business and personal contacts...?˘ organization Note: You are not required to store the contact information.... Include a prompt that allows the user to enter the following identifiable information
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1

Ads