December 16, 2009 at 3:39 PM
Hi Friend,
We have create a loop for only 3 items, you can modify it to 10.
import java.io.*;
import java.util.*;
public class SALE {
public static void main(String[] args) throws Exception {
ArrayList l1=new ArrayList();
ArrayList l2=new ArrayList();
ArrayList l3=new ArrayList();
ArrayList l4=new ArrayList();
ArrayList l5=new ArrayList();
ArrayList l6=new ArrayList();
ArrayList l7=new ArrayList();
double sum=0.0,sum1=0.0,sum2=0.0,sum3=0.0,sum4=0.0,sum5=0.0,sum6=0.0,sum7=0.0,p11=0.0,p12=0.0,p13=0.0,p21=0.0,p22=0.0,p23=0.0,p31=0.0,p32=0.0,p33=0.0,p41=0.0,p42=0.0,p43=0.0,p51=0.0,p52=0.0,p53=0.0,p61=0.0,p62=0.0,p63=0.0,p71=0.0,p72=0.0,p73=0.0,pp1=0.0,pp2=0.0,pp3=0.0;
Scanner scan = new Scanner(System.in);
int menu = 0;
System.out.println("Main Menu");
System.out.println();
System.out.println("1. Monday");
System.out.println("2. Tuesday");
System.out.println("3. Wednesday");
System.out.println("4. ThursDay");
System.out.println("5. Friday");
System.out.println("6. Saturday");
System.out.println("7. Sunday");
System.out.println("8. Exit");
double itemname[]=new double[3];
boolean quit = false;
do{
System.out.print("Please enter your choice: ");
menu = scan.nextInt();
System.out.println();
switch(menu) {
case 1:
for(int i=1;i<=3;i++){
System.out.print("Item Name:");
String name1=scan.next();
System.out.print("Quantity");
int q1=scan.nextInt();
System.out.print("Price");
double p1=scan.nextDouble();
double t1=p1*q1;
l1.add(t1);
sum1+=t1;
}
p11=Double.parseDouble((l1.get(0)).toString());
p12=Double.parseDouble((l1.get(1)).toString());
p13=Double.parseDouble((l1.get(2)).toString());
System.out.println(p11);
break;
case 2:
for(int i=1;i<=3;i++){
System.out.print("Item Name:");
String name2=scan.next();
System.out.print("Quantity");
int q2=scan.nextInt();
System.out.print("Price");
double p2=scan.nextDouble();
double t2=p2*q2;
l2.add(t2);
sum2+=t2;
}
p21=Double.parseDouble((l2.get(0)).toString());
p22=Double.parseDouble((l2.get(1)).toString());
p23=Double.parseDouble((l2.get(2)).toString());
System.out.println(p21);
break;
case 3:
for(int i=1;i<=3;i++){
System.out.print("Item Name:");
String name3=scan.next();
System.out.print("Quantity");
int q3=scan.nextInt();
System.out.print("Price");
double p3=scan.nextDouble();
double t3=p3*q3;
l3.add(t3);
sum3+=t3;
}
p31=Double.parseDouble((l3.get(0)).toString());
p32=Double.parseDouble((l3.get(1)).toString());
p33=Double.parseDouble((l3.get(2)).toString());
System.out.println(p31);
break;
case 4:
for(int i=1;i<=3;i++){
System.out.print("Item Name:");
String name4=scan.next();
System.out.print("Quantity");
int q4=scan.nextInt();
System.out.print("Price");
double p4=scan.nextDouble();
double t4=p4*q4;
l4.add(t4);
sum4+=t4;
}
p41=Double.parseDouble((l4.get(0)).toString());
p42=Double.parseDouble((l4.get(1)).toString());
p43=Double.parseDouble((l4.get(2)).toString());
System.out.println(p41);
break;
Related Tutorials/Questions & Answers:
Class SALE - Java BeginnersClass SALE A company
sale 10 items at different rates and details....
import java.io.*;
import java.util.*;
public
class SALE {
public static void... to Sunday. Write calss
SALE to enter
sale amount for each item, compute
classclass Is a
class a subclass of itself
Advertisements
class is a
class to represent a country in medal tally. It has an attribute of
country...
medals. In this
class, you should also define constructors, and assessor, mutator
methods.
Task 2
MedalTally.java is a
class to model a medal tally, containing
Class Class, Object and Methods
Class : Whatever we can see in this world all
the things... is termed as
a
class. All the
objects are direct interacted with its
class Java Class Question?Java
Class Question? Create a
class names Purchase Each purchase contains an invoice number, amount of
sale and amount of sales tax. Include set methods for the invoice number and
sale amount. Within the set() method
Super class of an Exception classSuper
class of an Exception class hello,,,
What is super
class of an Exception
class?
hii,,ADS_TO_REPLACE_1
the super
class of an exception is throwable
class. and the super
class of an throwable
class Point of Sale - Java BeginnersPoint of
Sale I am to create a java application that displays a GUI for a point of
sale pogram. I have to GUI created, but I am not sure how to get... java.text.NumberFormat;
import java.awt.event.*;
public
class PosGUI extends
implement sale purchaesimplement
sale purchaes i want to implement a code in advance java with connectivity ..
i have a table in database in which i have some stack of sms if customer puchases and enter value in text box the amount will be deduct
code for implementing sale purchasecode for implementing
sale purchase i have two tables in database. in one table i have stock of sms and further details and other table is for customer .if customer purchases my sms then the value will be deduct from my table
Class
Class
This section explores the concept of
a
class in reference to object oriented programming techniques. A
class defines
the properties of objects and methods used
class loadersclass loaders
Explain static and dynamic
class loaders
class fileclass file How to create
class file in jsf easily
inner classinner class what is mean by inner
class
Inner
class is a non-static
class which is defined inside another
class Node class Node
class hii,
What is a node
class?
hello,ADS_TO_REPLACE_1
A node
class is a
class that has added new services or functionality beyond the services inherited from its base
class Matrix Class Matrix
Class A
class to manage matrices and add them. Create in the driver
class two objects of it and use the add method
Matrix Class Matrix
Class A
class to manage matrices and add them. Create in the driver
class two objects of it and use the add method
lock on a classlock on a class hello,
Can a lock be acquired on a
class?
hiii,,ADS_TO_REPLACE_1
Yes, a lock can be acquired on a
class. This lock is acquired on the
class's Class object
Java classJava class What is the purpose of the Runtime
class robot classrobot class please send me uses of robot
class and some examples using robot
class Nested classNested class What is nested
class? when a
class is defined within another
class then such a
class is called a nested
class. Nested... readable and maintainable code.
class OuterClass {
...
static
class Calculate Company's Sale using Java*;
import java.util.*;
public
class SALE {
public static void main(String[] args... to calculate Company's
sale. A company sales 3 items at different rates and details...:
a) The total weekly
sale of the company
b) The total
sale of each item at the end
class fileclass file how to convert java classfile into java sourcefile
abstract classabstract class Can there be an abstract
class with no abstract methods
Adapter ClassAdapter Class Hello Everybody, Can anybody help me to describe what is Adapter
class and when to use this
class and give a suitable example... visit the following links:
What is Adapter
Class
Example of Adapter
Class super classsuper class which is the super base
class in java
wrapper classwrapper class why wrapper
class does not have a default constructor