Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
125 views3 pages

Design A Class With The Following Specifications

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views3 pages

Design A Class With The Following Specifications

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

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

Commerce and
>= 200 and < 300
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. Or
Define a class called with the following specifications:
Class name: Eshop
Member variables:
String name: name of the item purchased
double price: Price of the item purchased
Member methods:
void accept(): Accept the name and the price of the item using the methods of Scanner class.
void calculate(): To calculate the net amount to be paid by a customer, based on the following
criteria:
Discoun
Price
t

1000 – 25000 5.0%

25001 – 57000 7.5 %

57001 – 100000 10.0%

More than
15.0 %
100000

void display(): To display the name of the item and the net amount to be paid.
Write the main method to create an object and call the above methods.
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
2. 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. Or
Design a class name ShowRoom with the following description:
Instance variables / Data members:
String name — To store the name of the customer
long mobno — To store the mobile number of the customer
double cost — To store the cost of the items purchased
double dis — To store the discount amount
double amount — To store the amount to be paid after discount
Member methods:
ShowRoom() — default constructor to initialize data members
void input() — To input customer name, mobile number, cost
void calculate() — To calculate discount on the cost of purchased items, based on following
criteria
Cost Discount (in percentage)

Less than or equal to ₹10000 5%

More than ₹10000 and less than or equal to ₹20000 10%

More than ₹20000 and less than or equal to ₹35000 15%

More than ₹35000 20%


void display() — To display customer name, mobile number, amount to be paid after discount.
Write a main method to create an object of the class and call the above member methods.
3. 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.

You might also like