# Calculate Company's Sale using Java

In this section, you will learn how to calculate Company's sale.

### Calculate Company's Sales Using Java

In this section, you will learn how to calculate Company's sale. A company sales 3 items at different rates and details of sales ( total amount) of each item are stored on weekly basis i.e. from Monday to Sunday. Through the following code, we have allowed the user to enter  the sales amount of each item on weekly basis and compute the following:
a) The total weekly sale of the company
b) The total sale of each item at the end of the week
c) Average sale per day

Here is the code:

```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);
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. Results,Company Sale");
double itemname[] = new double[3];
boolean quit = false;
do {
System.out.println();

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;
sum1 += t1;
}
p11=Double.parseDouble((l1.get(0)).toString());
p12=Double.parseDouble((l1.get(1)).toString());
p13=Double.parseDouble((l1.get(2)).toString());
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;
sum2 += t2;
}
p21=Double.parseDouble((l2.get(0)).toString());
p22=Double.parseDouble((l2.get(1)).toString());
p23=Double.parseDouble((l2.get(2)).toString());
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;
sum3 += t3;
}
p31=Double.parseDouble((l3.get(0)).toString());
p32=Double.parseDouble((l3.get(1)).toString());
p33=Double.parseDouble((l3.get(2)).toString());
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;
sum4 += t4;
}
p41=Double.parseDouble((l4.get(0)).toString());
p42=Double.parseDouble((l4.get(1)).toString());
p43=Double.parseDouble((l4.get(2)).toString());
break;
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;
sum5 += t5;
}
p51=Double.parseDouble((l5.get(0)).toString());
p52=Double.parseDouble((l5.get(1)).toString());
p53=Double.parseDouble((l5.get(2)).toString());
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;
sum6 += t6;
}
p61=Double.parseDouble((l6.get(0)).toString());
p62=Double.parseDouble((l6.get(1)).toString());
p63=Double.parseDouble((l6.get(2)).toString());
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;
sum7 += t7;
}
p71=Double.parseDouble((l7.get(0)).toString());
p72=Double.parseDouble((l7.get(1)).toString());
p73=Double.parseDouble((l7.get(2)).toString());
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:"+pp1);
System.out.println("Total sale of Item2:"+pp2);
System.out.println("Total sale of Item3:"+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);
}
}
```