question archive Create a class Person with the following private member variables String name char gender int age Include appropriate getters and setters method Create a class BusTicket with the following private member variables int ticketNo float ticketPrice float totalAmount Person person Include appropriate getters and setters method  Write the following method in the BusTicket class void calculateTotal()—this method should calculate the total and set it based on the discount given below: For Children whose age is less than 16, give 50% discount For Senior citizen whose age is greater than or equal to 60 give 25% discount For Ladies give 10% discount No discount for remaining category

Create a class Person with the following private member variables String name char gender int age Include appropriate getters and setters method Create a class BusTicket with the following private member variables int ticketNo float ticketPrice float totalAmount Person person Include appropriate getters and setters method  Write the following method in the BusTicket class void calculateTotal()—this method should calculate the total and set it based on the discount given below: For Children whose age is less than 16, give 50% discount For Senior citizen whose age is greater than or equal to 60 give 25% discount For Ladies give 10% discount No discount for remaining category

Subject:Computer SciencePrice:5.87 Bought7

Create a class Person with the following private member variables

  • String name
  • char gender
  • int age

Include appropriate getters and setters method Create a class BusTicket with the following private member variables

  • int ticketNo
  • float ticketPrice
  • float totalAmount
  • Person person

Include appropriate getters and setters method 

Write the following method in the BusTicket class

void calculateTotal()—this method should calculate the total and set it based on the discount given below:

  1. For Children whose age is less than 16, give 50% discount
  2. For Senior citizen whose age is greater than or equal to 60 give 25% discount
  3. For Ladies give 10% discount
  4. No discount for remaining category. 

Based on above condition calculate total price. Create TestMain class which has main method and do the following input and output process .

To get the input write a method

public static BusTicket getTicketDetails() - Get the inputs relevant to BusTicket in this method and return the BusTicket object. Call this method in the main method, using the returned object invoke the method calculateTotal and print the output accordingly  

Note: Define all the attributes as private and methods as public.

Sample input 1:

Enter the passenger name:

vivek

Enter the gender(M or F / m or f):

M

Enter the age:

16

Enter the ticket no:

123

Enter the ticket price:

100.0

Option 1

Low Cost Option
Download this past answer in few clicks

5.87 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 7 times

Completion Status 100%

Related Questions