Computer Science, asked by harshit23619, 11 months ago

Define a class taximeter having the following description:

Data members/instance variables

int taxino - to store taxi number

String name - to store passenger's name

int km - to store number of kilometres travelled

Member functions:

taximeter() -- constructor to initialize taxino to 0, name to “ ”and b to 0.

input() - to store taxino,name,km

calculate() - to calculate bill for a customer according to given conditions

kilometers travelled(km) Rate/km

1 km Rs 25

1 km 6 Rs 10

6 < km 12 Rs 15

12 < km 18 Rs 20

>18 km Rs 25

display()- To display the details in the following format

Taxino Name Kilometres travelled Bill amount

- - - -

Create an object in the main method and call all the above methods in it. java program​

Answers

Answered by atif7189
0

Answer:

Search ncrt books and you will find the answer

Answered by zuhasyed07
0

Answer:

Hello..

Hope it helped you !!

Explanation:

import java.util.*;

public class taximeter

{

   int taxino;  

  String name;  

  int km;  

  int b;  

 

taximeter()  

      {  

      taxino=0;  

      name="";  

      km=0;  

      b=0;  

  }

  void input()  

  {  

      Scanner sc=new Scanner(System.in);  

      System.out.println("Enter the Taxi number ");

       taxino=sc.nextInt();  

      System.out.println("Enter the name ");

      name=sc.nextLine();  

      System.out.println("Enter the distance travelled ");  

      km=sc.nextInt();  

  }

  void calculate()  

  {

       if(km<=1)  

      b=25;  

      if(km>1 && km<=6)  

      b=10;

      if(km>6 && km<=12)  

      b=15;  

      if(km>12 && km<=18)  

      b=20;  

      if(km>18)  

      b=25;

    }

  void display()  

  {

     System.out.println("Taxi number, Name, Kilometers travelled, Bill amount  ");  

      System.out.println(taxino+"  "+name+"  "+km+" "+b+"  ");

    }

  public static void main(String args[])  

  {  

      taximeter ob= new taximeter();  

      ob.input();  

      ob.calculate();  

      ob.display();  

  }  

}

Similar questions