Computer Science, asked by vaishnavitolia00, 5 months ago

Question 1

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 <=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.

Answers

Answered by MOHDAFAN
3

Answer:

HEY FRIEND IT'S VERY LONG QUESTION

Explanation:

PLEASE MARK ME AS BRAINLIST

Answered by nishanthjayapal07
0

import java.util.*;

public class taximeter

{

   int taxino;

   String name;

   int km;

   int b;

   taximeter()

   {  

       taxino = 0;

       name = " ";

       b = 0;

   }

   

   void input()

   {  

       Scanner sc = new Scanner (System.in);

       System.out.println("Enter taxi number: ");

       taxino = sc.nextInt();

       System.out.println("Enter passanger's name: ");

       name = sc.nextLine();

       System.out.println("Enter number of kilometers travelled: ");

       km = sc.nextInt();

   }

   

   void calculate()

   {

       if (km<1||km==1)

       {

           b = 25;

       }

       else if (1<km&&km<6||km==6)

       {

           b = 10;

       }

       else if (6<km&&km<12||km==12)

       {

           b = 15;

       }

       else if (12<km&&km<18||km==18)

       {

           b = 20;

       }

       else if (km>18)

       {

           b = 25;

       }

   }

   

   void display()

   {

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

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

   }

   public static void main (String args[])

   {

   taximeter obj = new taximeter();

   obj.input();

   obj.calculate();

   obj.display();

   }

}

Similar questions