Page 154 - CA_Blue( J )_Class10
P. 154
ShowRoom()
{
name = "";
mobno = 0L;
cost = 0.0;
dis = 0.0;
amount = 0.0;
}
void input()
{
Scanner sc= new Scanner(System.in);
System.out.print("Enter Customer name: ");
name = sc.next();
System.out.print("Enter Mobile Number: ");
mobno = sc.nextLong();
System.out.print("Enter Cost: ");
cost = sc.nextDouble();
}
void calculate()
{
if(cost <= 10000)
dis = 5.0;
else if(cost <= 20000)
dis = 10.0;
else if(cost <= 35000)
dis = 15.0;
else
dis = 20.0;
dis = dis / 100.0 * cost;
amount = cost - dis;
}
void display()
{
System.out.println("Customer name: " + name);
System.out.println("Mobile Number: " + mobno);
System.out.println("Amount: " + amount);
}
public static void main()
{
ShowRoom obj = new ShowRoom();
obj.input();
obj.calculate();
obj.display();
}
}
17. Design a class RailwayTicket with the following description:
Instance variables/data members:
String name : to store the name of the customer.
String coach : to store the type of coach the customer wants to travel.
long mobno : to store customer's mobile number.
int amt : to store the basic amount of ticket.
int totalamt : to store the amount to be paid after updating the original amount.
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:
152152 Touchpad Computer Applications-X

