Skip to content

Commit c1d0087

Browse files
2 parents 7852cba + 1bd84d6 commit c1d0087

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

PersonStudent.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
public class Person {
2+
String name;
3+
Person(String name)
4+
{
5+
this.name=name;
6+
}
7+
}
8+
class Student extends Person
9+
{
10+
String CollegeName;
11+
12+
public Student(String name, String CollegeName) {
13+
super(name);
14+
this.CollegeName = CollegeName;
15+
}
16+
}
17+
class Teacher extends Person
18+
{
19+
int salary;
20+
String subject;
21+
22+
public Teacher(String name,int salary, String subject) {
23+
super(name);
24+
this.salary = salary;
25+
this.subject = subject;
26+
}
27+
void display()
28+
{
29+
System.out.println(name+" "+salary+" "+subject);
30+
}
31+
}
32+
class CollegeStudent extends Student
33+
{
34+
int year;String major;
35+
36+
public CollegeStudent(String name, String collegeName, int year, String major) {
37+
super(name, collegeName);
38+
this.year = year;
39+
this.major = major;
40+
}
41+
void display()
42+
{
43+
System.out.println(name+" "+CollegeName+" "+year+" "+major);
44+
}
45+
}
46+
class PersonStudent
47+
{
48+
public static void main(String[] args) {
49+
CollegeStudent obj1=new CollegeStudent("Mradul","GLA",2,"CS");
50+
Teacher obj2=new Teacher("Neeraj",200000,"OOP");
51+
obj1.display();
52+
obj2.display();
53+
}
54+
}

Purchase.java

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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

Comments
 (0)