0% found this document useful (0 votes)
1 views2 pages

Algorithm

Uploaded by

dipakgupta9883
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

Algorithm

Uploaded by

dipakgupta9883
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ALGORITHM :

1. Start: Import [Link].* package for using. Scanner class.

2. Declare Class : Create a class named Taxibill with data members:

String n --------> to store customer's name.


double d ---------> to store the distance travelled in kilometers.

3. Constructor Initialization:

Set n to an mpty String “”


Set d to 0.0

4. Accept method:
Create a scanner object sc to take user input
Promt "Enter Customer Name” and read n using next line()
Promt “Enter distance Travelled in km” and read d using nextdouble ()

5. Compute Method:
Initialize bill as 0.0
If d<=3 set bill = 45.0
else if d<=10 Set bill = 45.0 + (d-3)*15
else if d<=35 Set bill = 45.0 + 105.0 (d-10)*16.20
else Set bill = 45.0+105.0+405.0+(d-35)*20
Return bill

6. Display Method:
Call compute() method and store in total
Print Customer Name: followed by n.
Return Distance Travelled: followed by d and “km”
Print Taxi Bill: Rs. followed by total

[Link] Method:

Create an object ob of classs Taxbill


Call accept() method to take input
Call display() method to show output

[Link] Ends
NOTE: DONT JUST BLINDLY COPY THE FULL ALGORITHM. IT IS DIFFERENT FOR DIFFERENT
PROGRAMS REPLACE WITH YOUR VARIABLES AND METHODS.

You might also like