-
Notifications
You must be signed in to change notification settings - Fork 5
/
exp6c.java
58 lines (53 loc) · 1.01 KB
/
exp6c.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
import java.util.*;
import java.net.*;
class Fruits
{
boolean ct;
Fruits(boolean c)
{
this.ct=c;
}
void display()
{
System.out.println("Is it countable : "+ct);
}
}
class Watermelon extends Fruits
{
int price,quantity;
Watermelon(boolean c,int q,int p)
{
super(c);
this.price=p ;
this.quantity=q ;
}
void show()
{
display();
System.out.println("Quantity : "+ quantity+"\nPrice : "+price);
}
}
class exp6c
{
public static void main(String[] args) throws Exception
{
Date d=new Date();
InetAddress ip = InetAddress.getLocalHost();
boolean c;
int pp,q;
Watermelon[] p=new Watermelon[3];
Scanner sc=new Scanner(System.in);
for(int i=0;i<3;p[i]=new Watermelon(c,pp,q),i++)
{
System.out.print("\nIs it countable : ");
c=sc.nextBoolean();
System.out.print("Enter price : ");
pp=sc.nextInt();
System.out.print("Enter quantity : ");
q=sc.nextInt();
}
for(int i=0;i<3;p[i].show(),i++);
System.out.println("Date : "+d);
System.out.println("Ip address : "+ip);
}
}