Page 479 - CA_Blue( J )_Class10
P. 479
Variable Description
NAME DATATYPE DESCRIPTION
str String Accept a sentence
cap String Store capital letter from sentence
small String Store small letter from sentence
digit String Store digit from sentence
capc int Count number of capital letters
smallc int Count number of small letters
digitc int Count number of digits letters
ch char Extract character from sentence
len int Length of the sentence
i int Loop variable
PROGRAMS ON ENCAPSULATION
Questions based on identifying the different variables like local, instance, arguments, private, public, class variable,
etc..
Design a class named departmental_shop with the following description:
Program 18 Instance variables/data members:
String cusname : to store the name of the customer.
long mobile : to store the mobile number of the customer.
double price : to store the cost of the items purchased.
double dis : to store the discount amount.
double bill : to store the amount to be paid after discount.
static int count : stores number of objects created
Member methods :
departmental_shop() : default constructor to initialize data members.
departmental_shop(String cn, long m, double p) : initializes the data members
void input() : to input customer name, mobile number, cost.
void calculate() : to calculate discount on the cost of purchased items, based on the
following criteria:
Cost Discount (in percentage)
<= Rs. 10000 5%
> Rs. 10000 and <= Rs.20000 10%
> Rs. 20000 and <= Rs.35000 15%
> Rs. 35000 20%
void display() : calls the calcualte() and 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
1 import java.util.*;
2 class departmental_shop
3 {
477
Internal Assessment 477

