Computer Science, asked by aashka22, 11 months ago

45. Define
Define a class called mobike with the following description
Tristance 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
void input
to input and store the details of the customer
void compute()
to compute the rental charge
The rent for a mobike is charged on the following basis
First five days
Rs. 500 per day.
Next five days
Rs. 400 per day.
Rest of the days
Rs. 200 per day.
void display ( to display the details in the following format
Bike No. Phone No. Name No. of days Charge
20​

Answers

Answered by crazysandra444
35

Answer:

if scanner as it is easy

Explanation:

import java.util.*

class mobike

{

public static void main (String args [] )

{

Scanner in = new Scanner (System.in);

int bno, phno, days, charge;

String name;

System.out.println("enter your name");

name=in.nextLine();

System.out.println("enter your phone number");

phno=in.nextInt();

System.out.println("enter your rent days");

days=in.nextInt();

if (days>0 && days<=5)

charge=days*500;

else if(days>5 && days<=10)

charge= (500*5)+((days-5)*400);

else

charge=(500*5)+(400*5)+((days-5)*200);

System.out.println("your total charge cost is"+charge);

}

}

Similar questions