-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomerMonthlyAnalysis.java
More file actions
50 lines (46 loc) · 1.37 KB
/
Copy pathcustomerMonthlyAnalysis.java
File metadata and controls
50 lines (46 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.*;
public class customerMonthlyAnalysis
{
int tot_price =0, p;
String[] prd_quan = new String[50];
int[] prd_price = new int[50];
Scanner customer = new Scanner(System.in);
int x1,x;
String cus_name1, cus_name;
public void scan()
{
System.out.println("Enter no. of products");
int x1 = customer.nextInt();
x = x1;
System.out.println("Enter the name");
String cus_name1 = customer.next();
cus_name = cus_name1;
for(int i=0,s=1;i<x;i++,s++)
{
System.out.println("\nEnter the product name,quantity " +s);
prd_quan[i] = customer.next();
System.out.println("\nEnter the product price for " +prd_quan[i]);
prd_price[i] = customer.nextInt();
}
}
public void display()
{
for(int i=0;i<x;i++)
{
tot_price = tot_price + prd_price[i];
}
System.out.println("Total price for "+x+" items is "+tot_price);
}
public void calculate()
{
p = tot_price /100; //Percentage for Rs. 10,000 salary
System.out.println("\nCustomer Ms./Mr. "+cus_name+" purchases "+x+" products. Monthly salary is Rs. 10,000. "+p+"% of salary is spent on purchases every month");
}
public static void main(String[] args)
{
customerMonthlyAnalysis g = new customerMonthlyAnalysis();
g.scan();
g.display();
g.calculate();
}
}