-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTinhGiaBan1.java
More file actions
41 lines (40 loc) · 1.35 KB
/
TinhGiaBan1.java
File metadata and controls
41 lines (40 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
package JAVA;
import java.util.*;
import java.text.*;
public class TinhGiaBan1 {
public static class Product{
private String id, name, dv;
private long phiVanChuyen, thanhTien, giaBan;
private float sl, giaNhap;
public Product(int id, String name, String dv, float giaNhap, float sl){
this.id="MH";
if (id<10){
this.id+="0";
}
this.id+=String.valueOf(id);
this.name=name;
this.dv=dv;
this.phiVanChuyen=Math.round(giaNhap*sl*5.0/100.0);
this.thanhTien=Math.round(giaNhap*sl +this.phiVanChuyen);
this.giaBan=Math.round(this.thanhTien +this.thanhTien*2.0/100.0);
}
@Override
public String toString() {
return id+" "+name+" "+dv+" "+phiVanChuyen+" "+thanhTien+" "+giaBan;
}
}
public static void main(String[] args) throws ParseException{
Scanner sc=new Scanner(System.in);
// int n=Integer.parseInt(sc.nextLine());
int n=sc.nextInt();
List<Product> a=new ArrayList<>();
for(int i=1;i<=n;i++){
sc.nextLine();
Product x=new Product(i, sc.nextLine(), sc.nextLine(), sc.nextFloat(), sc.nextFloat());
a.add(x);
}
for(Product i:a){
System.out.println(i);
}
}
}