-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mobike.java
75 lines (68 loc) · 1.88 KB
/
Mobike.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
75
/*Define a class called mobike with the following description: Instance variables/data members:
int bno -to store the bike's number
int phno-to store the phone number of the customer
String name - to store the name of the customer.
int days- to store the number of days the bike is taken on rent.
int charge -to calculate and store the rental charge.
Member methods:
voidinput() -to input and store the detail of the Customer.
void compute() - to compute the rental charge.
The rent for a mobike is charged on the following basis
First five days 500 per day.
Next five days 400 per day.
Rest of the days 200 per day
void display ()- to display the details in the following format:
Bike No. Phone No. Name No. of days Charge */
import java.util.*;
public class Mobike
{
int bno,days,charge;
long phno;
String name;
Mobike()
{
bno=0;
phno=0l;
days=0;
charge=0;
name="";
}
public void input()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter your name,bike number,phone number,days=");
name=sc.next();
bno=sc.nextInt();
phno=sc.nextLong();
days=sc.nextInt();
}
public void compute()
{
if(days<=5)
{
charge=days*500;
}
if(days>5)
{
charge=5*500+(days-5)*400;
}
if(days>10)
{
charge=5*500+5*400+(days-10)*200;
}
}
public void display()
{
System.out.println("Bike No.\tPhone No.\tName\tNo. of days");
System.out.println(bno+"\t"+phno+"\t"+name+"\t"+days);
System.out.println("Your charge="+charge);
System.out.println("THANK YOU,VISIT AGAIN!!!!!!!!");n
}
public static void main(String args[])
{
Mobike obj=new Mobike();
obj.input();
obj.compute();
obj.display();
}
}