-
Notifications
You must be signed in to change notification settings - Fork 0
/
EndTermQ4.java
74 lines (70 loc) · 2.13 KB
/
EndTermQ4.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
package JavaPrograms;
import java.util.Scanner;
class Author
{
String name;
String email;
public Author(String str,String str2)
{
name=str;
email=str2;
}
public void show1()
{
System.out.println("Name : "+name+" <-::-> Email id : "+email);
}
}
class Book
{
int price;
int quantity;
String name;
String email;
public Book(int price,int quantity,String name,String email)
{
this.price=price;
this.quantity=quantity;
this.name=name;
this.email=email;
}
public void object()
{
Author obj = new Author(name,email);
obj.show1();
}
}
public class EndTermQ4 {
public static void main(String arg[])
{
System.out.println("Enter the name of the author of the book1 ");
Scanner s = new Scanner(System.in);
String str1 = s.nextLine();
System.out.println("Enter the price of the book1 ");
Scanner s1 = new Scanner(System.in);
int x = s1.nextInt();
System.out.println("Enter the quantity of the book1 ");
Scanner s2 = new Scanner(System.in);
int y = s2.nextInt();
System.out.println("Enter the email id of the author ");
Scanner s3 = new Scanner(System.in);
String str2 = s3.nextLine();
Book obj2 = new Book(x,y,str1,str2);
System.out.println("Enter the name of the author of the book2 ");
Scanner s4 = new Scanner(System.in);
String str3 = s4.nextLine();
System.out.println("Enter the price of the book2 ");
Scanner s5 = new Scanner(System.in);
int x2 = s5.nextInt();
System.out.println("Enter the quantity of the book2 ");
Scanner s6 = new Scanner(System.in);
int y2 = s6.nextInt();
System.out.println("Enter the email id of the author2 ");
Scanner s7 = new Scanner(System.in);
String str4 = s7.nextLine();
Book obj3 = new Book(x2,y2,str3,str4);
if(obj2.price>obj3.price)
obj2.object();
else
obj3.object();
}
}