Mobike Program in Java

Define a class called Mobike with the following description:
Instance variables/data members:
String bno – to store the bike’s number(UP65AB1234)
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 detail of the customer.
void compute( ) – to compute the rental chargeThe 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 dayvoid display ( ) – to display the details in the following format:
Bike No. PhoneNo. No. of days Charge

import java.util.Scanner;

public class Mobike
{
    String bno;
    String name;
    int days;
    int charge;
    public void input()
    {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter your bike number= ");
        bno = scanner.nextLine();
        System.out.print("Enter your name= ");
        name = scanner.nextLine();
        System.out.print("Enter number of days= ");
        days = scanner.nextInt();
    }
    public void compute()
    {
        if (days <= 5)
        {
            charge = 500 * days;
        }
        else if (days <= 10)
        {
            charge = 5 * 500 + (days - 5) * 400;
        }
        else
        {
            charge = 5 * 500 + 5 * 400 + (days - 10) * 200;
        }
    }
    public void display()
    {
        System.out.println("Bike No.="+bno);
        System.out.println("Name="+name);
        System.out.println("Days="+days);
        System.out.println("Charge="+charge);        
    }
    public static void main(String[] args)
    {
        Mobike mobike=new Mobike();
        mobike.input();
        mobike.compute();
        mobike.display();
    }
}


Output:

Enter your bike number= UP65
Enter your name= Afaq Ahmad
Enter number of days= 12
Bike No.=UP65
Name=Afaq Ahmad
Days=12
Charge=4900
java java tutorials learn java study java