|
| 1 | +import java.util.Scanner; |
| 2 | + |
| 3 | +public class Customer_Purchases { |
| 4 | + private long customer_number; |
| 5 | + private String first_name,surname,product; |
| 6 | + private int price,quantity; |
| 7 | + |
| 8 | + public long getCustomer_number() { |
| 9 | + return customer_number; |
| 10 | + } |
| 11 | + |
| 12 | + public void setCustomer_number(long customer_number) { |
| 13 | + this.customer_number = customer_number; |
| 14 | + } |
| 15 | + |
| 16 | + public String getFirst_name() { |
| 17 | + return first_name; |
| 18 | + } |
| 19 | + |
| 20 | + public void setFirst_name(String first_name) { |
| 21 | + this.first_name = first_name; |
| 22 | + } |
| 23 | + |
| 24 | + public String getSurname() { |
| 25 | + return surname; |
| 26 | + } |
| 27 | + |
| 28 | + public void setSurname(String surname) { |
| 29 | + this.surname = surname; |
| 30 | + } |
| 31 | + |
| 32 | + public String getProduct() { |
| 33 | + return product; |
| 34 | + } |
| 35 | + |
| 36 | + public void setProduct(String product) { |
| 37 | + this.product = product; |
| 38 | + } |
| 39 | + |
| 40 | + public int getPrice() { |
| 41 | + return price; |
| 42 | + } |
| 43 | + |
| 44 | + public void setPrice(int price) { |
| 45 | + this.price = price; |
| 46 | + } |
| 47 | + |
| 48 | + public int getQuantity() { |
| 49 | + return quantity; |
| 50 | + } |
| 51 | + |
| 52 | + public void setQuantity(int quantity) { |
| 53 | + this.quantity = quantity; |
| 54 | + } |
| 55 | +} |
| 56 | +class Printing |
| 57 | +{ |
| 58 | + Customer_Purchases obj=new Customer_Purchases(); |
| 59 | + void printDetails() |
| 60 | + { |
| 61 | + System.out.println(obj.getFirst_name()+" "+obj.getSurname()); |
| 62 | + System.out.println(obj.getCustomer_number()); |
| 63 | + System.out.println(obj.getProduct()+" Rs."+obj.getPrice()+" "+obj.getQuantity()+" piece"); |
| 64 | + customerPurchaseReport(); |
| 65 | + } |
| 66 | + void customerPurchaseReport() |
| 67 | + { |
| 68 | + float total=obj.getQuantity()*obj.getPrice(); |
| 69 | + float tax=(15*total/100); |
| 70 | + float commission=8.5f*total/100; |
| 71 | + float discount=10*total/100; |
| 72 | + total=total+tax-(discount+commission); |
| 73 | + System.out.println(" Tax =15% = Rs."+tax); |
| 74 | + System.out.println("Commission =8.5%=Rs."+commission); |
| 75 | + System.out.println("Discount=10%=Rs."+discount); |
| 76 | + System.out.println("Total =Rs."+total); |
| 77 | + } |
| 78 | +} |
| 79 | +class Purchase |
| 80 | +{ |
| 81 | + public static void main(String[] args) { |
| 82 | + Scanner sc=new Scanner(System.in); |
| 83 | + Printing ob=new Printing(); |
| 84 | + System.out.println("Enter first name, surname ,number,product,price,quantity"); |
| 85 | + ob.obj.setFirst_name(sc.next()); |
| 86 | + ob.obj.setSurname(sc.next()); |
| 87 | + ob.obj.setCustomer_number(sc.nextLong()); |
| 88 | + ob.obj.setProduct(sc.next()); |
| 89 | + ob.obj.setPrice(sc.nextInt()); |
| 90 | + ob.obj.setQuantity(sc.nextInt()); |
| 91 | + ob.printDetails(); |
| 92 | + } |
| 93 | +} |
0 commit comments