Login


Lost your password?

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


Shop
Java All : Defining Classes


Exam Paper Problems

Class Design – Railway Ticket #7188

( As In Exam - ICSE2018 )

Design a class RailwayTicket with following description:

Instance vari

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.

Class definition – Electric Bill #7253

( As In Exam - ICSE2017 )

Define a class ElectricBill with the following specification

Define a class ElectricBill with the following specifications:

class : ElectricBill
Instance variables / data member:
String n – to store the name of the customer
int units – to store the number of units consumed
double bill – to store the amount to be paid
Member methods:
void accept( ) – to accept the name of the customer and number of units consumed
void calculate( ) – to calculate the bill as per the following tariff:
Number of units Rate per unit
First 100 units Rs.2.00
Next 200 units Rs.3.00
Above 300 units Rs.5.00
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
void print ( ) – To print the details as follows:
Name of the customer: ………………………
Number of units consumed: ………………………
Bill amount: ………………………
Write a main method to create an object of the class and call the above member methods.

04-2016 #7316

( As In Exam - ICSE2016 )

Define a class named BookFair with the following description: [15]
Inst

Define a class named BookFair with the following description: [15]
Instance variables/Data members:
String Bname – stores the name of the book.
double price – stores the price of the book.
Member Methods:
(i) BookFair() – Default constructor to initialize data members.
(ii) void Input() – To input and store the name and the price of the book.
(iii) void calculate() – To calculate the price after discount. Discount is calculated based on the following criteria.
PRICE DISCOUNT
Less than or equal to Rs 1000 2% of price
More than Rs 1000 and less than or equal to Rs 3000 10% of price
More than Rs 3000 15% of price
(iv) void display() – To display the name and price of the book after discount.
Write a main method to create an object of the class and call the above member methods.



Exam Paper Problems:3 
Back