-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathGenerateInvoice.java
136 lines (113 loc) · 3.62 KB
/
GenerateInvoice.java
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
public class Invoice
{
private int item_number;
private String name;
private int quantity;
private double price;
private double total_cost;
public Invoice(int item_num, String nm, int quan, double pri)
{
item_number = item_num;
name = nm;
quantity = quan;
price = pri;
total_cost = 0;
}
public int getitem_number()
{
return item_number;
}
public String getname()
{
return name;
}
public int getquantity()
{
return quantity;
}
public double getprice()
{
return price;
}
public double gettotal_cost()
{
return total_cost;
}
public void setitem_number( int item_n)
{
item_number = item_n;
}
public void setname(String n)
{
name = n;
}
public void setquantity(int quan)
{
quantity = quan;
total();
}
public void setprice(double pri)
{
price = pri;
total();
}
public void total()
{
total_cost = price * quantity;
}
public void displayLine()
{
System.out.println("Item Number: "+item_number);
System.out.println("Name: "+name);
System.out.println("Quantity: "+quantity);
System.out.println("Price: "+price);
System.out.println("Total Cost: "+total_cost);
}
}
//-----------------------------------------------------------
import java.util.Scanner;
public class InvoiceDriver {
public static void main(String[] args) {
Invoice check1 = new Invoice(112, "Book", 3, 125.98);
Invoice check2 = new Invoice(101, "Phone", 2, 456.35);
Invoice check3 = new Invoice(187, "Laptop", 1, 2345.68);
items(check1,check2, check3);
}
public static void items(Invoice chk1, Invoice chk2, Invoice chk3)
{
Scanner sn = new Scanner(System.in);
//-----------------------------------------------------------
System.out.println("Please enter Item Number: ");
chk1.setitem_number(sn.nextInt());
System.out.println("Please enter Item Name: ");
chk1.setname(sn.next());
System.out.println("Please enter quantity: ");
chk1.setquantity(sn.nextInt());
System.out.println("Please enter price: ");
chk1.setprice(sn.nextDouble());
//-----------------------------------------------------------
//-----------------------------------------------------------
System.out.println("Please enter Item Number: ");
chk2.setitem_number(sn.nextInt());
System.out.println("Please enter Item Name: ");
chk2.setname(sn.next());
System.out.println("Please enter quantity: ");
chk2.setquantity(sn.nextInt());
System.out.println("Please enter price: ");
chk2.setprice(sn.nextDouble());
//-----------------------------------------------------------
//-----------------------------------------------------------
System.out.println("Please enter Item Number: ");
chk3.setitem_number(sn.nextInt());
System.out.println("Please enter Item Name: ");
chk3.setname(sn.next());
System.out.println("Please enter quantity: ");
chk3.setquantity(sn.nextInt());
System.out.println("Please enter price: ");
chk3.setprice(sn.nextDouble());
//-----------------------------------------------------------
chk1.displayLine();
chk2.displayLine();
chk3.displayLine();
}
}