Class Design – Railway Ticket – Computer Sir Ki Class


Lost your password?

Don't have an account ?
Register (It's FREE) ×


Exam Questions-ICSE2018-04A #JAVA#7188    siteicon   siteicon  

Problem Statement - Class Design – Railway Ticket

Design a class RailwayTicket with following description:

Instance variables/data members :
String name : To store the name of the customer
String coach : To store the type of coach customer wants to travel
long mobno : To store customer’s mobile number
int amt : To store basic amount of ticket
int totalamt : To store the amount to be paid after updating the original amount
Member methods :
void accept () – To take input for name, coach, mobile number and amount.
void update() – To update the amount as per the coach selected
(extra amount to be added in the amount as follows)

Type of Coaches Amount
First_AC 700
Second_AC 500
Third_AC 250
sleeper None

void display() – To display all details of a customer such as name, coach, total amount and mobile number.
Write a main method to create an object of the class and call the above member methods.


TC++ #7188

Run Output

Enter name: Nani
Enter coach: First_AC
Enter mobno: 9999999999
Enter amt: 3000
Name: Nani
Coach: First_AC
Mobile Number: 9999999999
Amount: 3000
Total Amount: 3700


CSKC| Created: 12-Apr-2019 | Updated: 26-Nov-2019|ICSE2018