-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
55 lines (50 loc) · 923 Bytes
/
Product.java
File metadata and controls
55 lines (50 loc) · 923 Bytes
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
import java.util.*;
class product
{
int pcode;
float price;
String pname;
void getdata()
{
System.out.println("enter pcode,pname,price");
Scanner sc=new Scanner(System.in);
this.pcode=sc.nextInt();
sc.nextLine();
this.pname=sc.nextLine();
sc.nextLine();
this.price=sc.nextFloat();
}
void displaydata()
{
System.out.println("pcode"+pcode);
System.out.println("pname"+pname);
System.out.println("price"+price);
}
}
class Product
{
public static void main(String args[])
{
product p1=new product();
product p2=new product();
product p3=new product();
p1.getdata();
p2.getdata();
p3.getdata();
p1.displaydata();
p2.displaydata();
p3.displaydata();
if((p1.price<p2.price)&&(p1.price<p3.price))
{
System.out.println("p1 is smaller");
}
else if((p2.price)<(p3.price))
{
System.out.println("p2 is smaller");
}
else
{
System.out.println("p3 is smaller");
}
}
}