Loading...
A private Cab service company provides service within the city at the following rates: | AC CAR | NON AC CAR UPTO 5 KM | ₹ 150 /- | ₹ 120 /- BEYOND 5 KM | ₹ 10/-PER KM | ₹ 08/- PER KM Design a class CabService with the following description: Member variables /data members: String car_type - To store the type of car (AC or NON AC) double km - To store the kilometer travelled double bill - To calculate and store the bill amount Member methods : CabService() - Default constructor to initialize data members. String data members to " " and double data members to 0.0. void accept () - To accept car_type and km (using Scanner class only). void calculate () - To calculate the bill as per the rules given above. void display() - To display the bill as per the following format CAR TYPE: KILOMETER TRAVELLED: TOTAL BILL: Create an object of the class in the main method and invoke the member methods.
The Scanner class method used to accept words with space:
Design a class with the following specifications: Class name: Student Member variables: name – name of student age – age of student mks –marks obtained stream – stream allocated (Declare the variables using appropriate data types) Member methods: void accept() – Accept name, age and marks using methods of Scanner class. void allocation() – Allocate the stream as per following criteria: mks | stream > = 300 | Science and Computer > = 200 and < 300 | Commerce and Computer > = 75 and 200 | Arts and Animation < 75 | Try Again void print() – Display student name, age, mks and stream allocated. Call all the above methods in main method using an object.
DTDC a courier company charges for the courier based on the weight of the parcel. Define a class with the following specifications: class name: courier Member variables: name – name of the customer weight – weight of the parcel in kilograms address – address of the recipient bill – amount to be paid type – ‘D’- domestic, ‘I’- international Member methods: void accept ( ) – to accept the details using the methods of the Scanner class only. void calculate ( ) – to calculate the bill as per the following criteria: Weight in Kgs | Rate per Kg First 5 Kgs | Rs.800 Next 5 Kgs | Rs.700 Above 10 Kgs | Rs.500 An additional amount of Rs.1500 is charged if the type of the courier is I (International) void print ( ) – To print the details void main ( ) – to create an object of the class and invoke the methods
Define a class named CloudStorage with the following specifications: Member Variables: int acno - stores the user's account number. int space - stores the amount of storage space in GB purchased by the user. double bill - stores the total price to be paid by the user. Member Methods: void accept() - prompts the user to input their account number and storage space using Scanner class methods only. void calculate() - calculates the bill total price based on the storage space purchased using the pricing table provided: Storage range | Price per GB (Rs) First 15 GB | 15 Next 15 GB | 13 Above 30 GB | 11 void display() - displays the account number, storage space and bill to be paid. Write a main method to create an object of the class and invoke the methods of the class with respect to the object.
© 2026 PadhAiPro. This question is provided for educational purposes.