-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA1q8.java
More file actions
45 lines (44 loc) · 887 Bytes
/
Copy pathA1q8.java
File metadata and controls
45 lines (44 loc) · 887 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
import java.util.*;
class fruit
{
String name;
int num;
float price;
fruit()
{
name="mango";
num=10;
price=20.00f;
}
void getfruit()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter name ");
name=sc.nextLine();
System.out.println("enter number of fruits ");
num=Integer.parseInt(sc.nextLine());
System.out.println("enter price ");
price=Float.parseFloat(sc.nextLine());
}
void displayfruit()
{
System.out.println("NAME OF FRUIT IS : "+name);
System.out.println("NUMBER OF FRUITS IS : "+num);
if(num==1)
System.out.println("single fruit");
else
System.out.println("bunch of fruits");
System.out.println("PRICE OF FRUIT IS : "+price);
}
}
class A1q8
{
public static void main(String []ar)
{
fruit f=new fruit();
fruit f1=new fruit();
f.displayfruit();
f1.getfruit();
f1.displayfruit();
}
}