Class SALE

Class SALE

View Answers

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;

December 16, 2009 at 3:40 PM

continue..

case 5:

for(int i=1;i<=3;i++){
System.out.print("Item Name:");
String name5=scan.next();
System.out.print("Quantity");
int q5=scan.nextInt();
System.out.print("Price");
double p5=scan.nextDouble();
double t5=p5*q5;
l5.add(t5);
sum5+=t5;
}
p51=Double.parseDouble((l5.get(0)).toString());
p52=Double.parseDouble((l5.get(1)).toString());
p53=Double.parseDouble((l5.get(2)).toString());
System.out.println(p51);
break;
case 6:

for(int i=1;i<=3;i++){
System.out.print("Item Name:");
String name6=scan.next();
System.out.print("Quantity");
int q6=scan.nextInt();
System.out.print("Price");
double p6=scan.nextDouble();
double t6=p6*q6;
l6.add(t6);
sum6+=t6;
}
p61=Double.parseDouble((l6.get(0)).toString());
p62=Double.parseDouble((l6.get(1)).toString());
p63=Double.parseDouble((l6.get(2)).toString());
System.out.println(p61);
break;
case 7:

for(int i=1;i<=3;i++){
System.out.print("Item Name:");
String name7=scan.next();
System.out.print("Quantity");
int q7=scan.nextInt();
System.out.print("Price");
double p7=scan.nextDouble();
double t7=p7*q7;
l7.add(t7);
sum7+=t7;
}
p71=Double.parseDouble((l7.get(0)).toString());
p72=Double.parseDouble((l7.get(1)).toString());
p73=Double.parseDouble((l7.get(2)).toString());
System.out.println(p71);
break;
case 8:
quit = true;
pp1=p11+p21+p31+p41+p51+p61+p71;
pp2=p12+p22+p32+p42+p52+p62+p72;
pp3=p13+p23+p33+p43+p53+p63+p73;
System.out.println("Total sale of Item1 is: "+pp1);
System.out.println("Total sale of Item2 is: "+pp2);
System.out.println("Total sale of Item3 is: "+pp3);
sum=sum1+sum2+sum3+sum4+sum5+sum6+sum7;
System.out.println("Total Weekly Sale= "+sum);
System.out.println("Average Weekly Sale per day= "+sum/7);
break;
default:
System.out.println("Invalid Entry!");
}
}
while (!quit);
}
}

Hope that the above code will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
Class SALE - Java Beginners
Class 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
class
class  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 class
Super 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
ModuleNotFoundError: No module named 'odoo8-addon-sale-order-type-sale-journal'
ModuleNotFoundError: No module named 'odoo8-addon-sale-order-type-sale-journal...: ModuleNotFoundError: No module named 'odoo8-addon-sale-order-type-sale-journal' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-sale-order
Total summay from a sale table
Total summay from a sale table  Total summay from a sale table
Point of Sale - Java Beginners
Point 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
ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-sale'
ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-sale'  Hi...: No module named 'odoo10-addon-l10n-br-sale' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-sale' error? Thanks  
ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-sale'
ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-sale'  Hi...: No module named 'odoo10-addon-l10n-br-sale' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-l10n-br-sale' error? Thanks  
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale'
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale'  Hi...: No module named 'odoo8-addon-l10n-br-sale' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale' error? Thanks  
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale'
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale'  Hi...: No module named 'odoo8-addon-l10n-br-sale' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale' error? Thanks  
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale'
ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale'  Hi...: No module named 'odoo8-addon-l10n-br-sale' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-l10n-br-sale' error? Thanks  
ModuleNotFoundError: No module named 'openerp-sale'
ModuleNotFoundError: No module named 'openerp-sale'  Hi, My Python... 'openerp-sale' How to remove the ModuleNotFoundError: No module named 'openerp-sale' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'trytond-sale'
ModuleNotFoundError: No module named 'trytond-sale'  Hi, My Python... 'trytond-sale' How to remove the ModuleNotFoundError: No module named 'trytond-sale' error? Thanks   Hi, In your python
implement sale purchaes
implement 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 purchase
code 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
Explain final class, abstract class and super class.
Explain final class, abstract class and super class.  Explain final class, abstract class and super class.   Explain final class, abstract class and super class. A final class cannot be extended. A final class
.class and .tld
.class and .tld  how to create .class and .tld file
class loaders
class loaders   Explain static and dynamic class loaders
class file
class file  How to create class file in jsf easily
inner class
inner 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
objective c extending a class with a class
objective c extending a class with a class  I need an example for extending a class with a class in objective c. thanks
objective c extending a class with a class
objective c extending a class with a class  I need an example for extending a class with a class in objective c. thanks
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
printstrim class
printstrim class  discribe PrintStream class
printstrim class
printstrim class  discribe PrintStream class
lock on a class
lock 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 class
Java class  What is the purpose of the Runtime class
immutable class
immutable class  How to make a class immutable
Locale class
Locale class  What is the Locale class
singleton class
singleton class  What is singleton class
Abstract class
Abstract class  Can an abstract class be final
Abstract class
Abstract class  what is an Abstract class
wrapper class
wrapper class  list wrapper class methods
wrapper class
wrapper class  wrapper class methods
robot class
robot class  please send me uses of robot class and some examples using robot class
Nested class
Nested 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 file
class file  how to convert java classfile into java sourcefile
abstract class
abstract class  Can there be an abstract class with no abstract methods
java.sql.DriverManager class
java.sql.DriverManager class  Why isn't the java.sql.DriverManager class being found
Adapter Class
Adapter 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
create a class
create a class  plz provide any example related to class
super class
super class  which is the super base class in java
wrapper class
wrapper class  why wrapper class does not have a default constructor

Ads