-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct_function.java
More file actions
54 lines (49 loc) · 1.35 KB
/
Copy pathproduct_function.java
File metadata and controls
54 lines (49 loc) · 1.35 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
51
52
53
package function;
import java.util.Scanner;
public final class product_function {
int code,qty,discount;
String name;
float price;
void Input(){
Scanner objin = new Scanner(System.in);
System.out.print("Input ID :"); code = objin.nextInt();
System.out.print("Input Qty :"); qty = objin.nextInt();
System.out.print("Input Name :"); name = objin.next();
System.out.print("Input Price :"); price = objin.nextFloat();
}
float Total(){
return price*qty;
}
float Discount(){
if(Total()>=100 && Total()<500)
{
discount = 10;
}
else if (Total()>=500 && Total() <1000)
{
discount = 20;
}
else if(Total()>=100 && Total() <2000)
{
discount = 30;
}
else{
discount = 50;
}
return discount;
}
double Payment(){
return Total()-Total()*Discount()/100;
}
void Output(){
System.out.println("Code\tQty\tName\tPrice\tDiscont\tTotal\tPayment");
System.out.println(code+"\t"+qty+"\t"+name+"\t"+price+"\t"+Discount()+"\t"+Total()+"\t"+Payment());
}
public product_function(){
Input();
Output();
}
public static void main(String[] args) {
new product_function();
}
}