[go: up one dir, main page]

0% found this document useful (0 votes)
40 views50 pages

FatimaZRahman Computers Project

This project, titled [Project Title], explores [Topic/Theme] to deepen our understanding of its concepts and applications. It aims to investigate [Objective 1], analyze [Objective 2], and offer insights into [Objective 3]. Through research and analysis, this project enhances our knowledge and problem-solving skills in [Subject/Class Name]. This project, titled [Project Title], explores [Topic/Theme] to deepen our understanding of its concepts and applications. It aims to investigate [Objec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views50 pages

FatimaZRahman Computers Project

This project, titled [Project Title], explores [Topic/Theme] to deepen our understanding of its concepts and applications. It aims to investigate [Objective 1], analyze [Objective 2], and offer insights into [Objective 3]. Through research and analysis, this project enhances our knowledge and problem-solving skills in [Subject/Class Name]. This project, titled [Project Title], explores [Topic/Theme] to deepen our understanding of its concepts and applications. It aims to investigate [Objec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

COMPUTER APPLICATIONS

FINAL PROJECT SUBMISSION

Fatima Zahra Rahman


Class 10D
Reference no. 3855

Page 1
INDEX

Program
Topic Page no.
no.

1 User-De ned Classes: Cab Service Bill 3

2 Arrays: Negative and Positive integers Array 6

3 Arrays: Assign Grade by Marks 8

4 Arrays: Binary Search 10

5 Norm of a Number 12

6 Patterns 14

7 User-De ned Classes: Festival Discount and Gifts 17

8 Double-Dimensional Arrays: Sum of Odd numbers and Product of Even 21


numbers

9 Double-Dimensional Arrays: Sum of Two Arrays 23

10 Double-Dimensional Arrays: Sum of Elements in a Row 26

11 Constructors & User-De ned Methods: Discount on a Purchase 28

12 User-De ned Classes: Overloading function for Sum of Series 32

13 Constructors & User-De ned Methods: Calculation of Telephone Bill 34

14 Arrays: Sorting by Bubble Sort method 37

15 String Handling: Replacing Vowels in a String with next Consonant 39

16 User-De ned Methods and String-Handling: Overloading functions to check for 41


palindromes

17 String-Handling: Names that begin and end with ‘A’ or ‘a’ 43

18 String-Handling: The Biggest and Smallest Words in a String array 45

19 String-Handling: Frequency of Characters in a Sentence 47

20 Patterns: String patter and Number pattern 49

Page 2
fi
fi
fi
fi
fi
fi
PROGRAM 1
De ne a class with the given speci cations and calculate the bill amount for a private Cab
service company which provides services within the city at the following rates:

AC CAR NON AC CAR

Upto 10 KM ₹ 170 /- ₹ 130 /-

Beyond 10 KM ₹ 30 /- per KM ₹ 20 /- per KM

Class name: InCity


Member variables: car_type: Stores type of the car (AC or NON AC)
km: Stores the kilometers travelled.
bill: Calculates and stores the bill amount

Member methods:
void accept( ) - Accepts car_type and km
void calculate( ) - Calculates the bill as per the rules given above.
void display( ) - Displays the bill

SOURCE CODE

Page 3
fi
fi
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

car_type String class InCity Stores the type of taxi (AC or


NON AC)

km int class InCity Stores the distance travelled


in kilometres

bill int class InCity Calculates and stores the bill


amount

obj Incity main() object of class InCity

sc Scanner class InCity Scanner class object to


invoke the methods of the
Scanner class

Page 4
OUTPUT

1)

2)

3)

4)

Page 5
PROGRAM 2
De ne a class to store 10 integers (including positive and negative numbers) in a Single
Dimensional Array (SDA). Display all the negative numbers followed by the positive
numbers. Also display the sum of the positive numbers.

SOURCE CODE

Page 6
fi
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

arr[ ] int main() Inputs and stores integers

neg String main() Stores the values of all the


negative numbers in the array

pos String main() Stores the values of all the


positive numbers in the array

sum int main() Calculates and stores the


sum of all the positive
integers in the array

i int for(i) loop counter for two loops in


the given source code

sc Scanner main() Scanner class object to


invoke the methods of the
Scanner class

OUTPUT

1)

2)

Page 7
PROGRAM 3
De ne a class to declare an array of double data type to store the following percentages
of marks scored by 10 students in an exam:
{98.3, 82.4, 99.0, 78.5, 89.1, 92.8, 99.8, 96.2, 97.6, 62.4}.

Declare another array of character data type which stores the corresponding grades as
per the following rules:

MARKS GRADE

95 or above A+

85 or above but below 95 A

70 or above but below 85 B

Below 70 C

SOURCE CODE

Page 8
fi
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

marks[ ] double main() To store marks of students

grade[ ] String main() To store grade of students


based on their marks

sc Scanner main() Scanner class object to


invoke the methods of the
Scanner class

OUTPUT

1)

Page 9
PROGRAM 4
De ne a class to declare an array of long data type to accept the registration numbers of
10 students in ascending order. Perform the Binary Search to search for an element
entered by the user. If it is found, display the message “Element found” along with its
position. Otherwise display the message “Search element not found”.

SOURCE CODE

Page 10
fi
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

arr[ ] long main() Stores registration numbers


of students

lb int main() Stores the lower bound of


the array for performing the
binary search

ub int main() Stores the upper bound of


the array for performing the
binary search

mid int main() Stores the middle value of


the array

f int main() Indicates whether the


search element is present in
the array

searchE int main() Stores the value of the


search element

i int for(i) Loop counter of for() loop

sc Scanner main() Scanner class object to


invoke the methods of the
Scanner class

OUTPUT

1)

2)

Page 11
PROGRAM 5
De ne a class to input an integer. Calculate and display the Norm of the number. The
Norm of a number is the square root of the sum of squares of all digits of the number.
Example : The Norm of 68 is 10.
6 x 6 + 8 x 8 = 36 + 64 = 100 ; square root of 100 is 10.

SOURCE CODE

VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

num int main() Stores number input from


user

r int main() Stores value of the last digit


of the number

copy int main() Stores a copy of ‘num’

norm double main() Caclulates and stores the


value of the ‘norm’ of the
number

sc Scanner main() Scanner class object to


invoke the methods of the
Scanner class

Page 12
fi
OUTPUT

1)

2)

Page 13
PROGRAM 6
Write a menu-driven program to display the pattern as per the user’s choice.

Pattern 1 Pattern 2
1 2 3 4 @@@@@
5 6 7 8 @@@@
9 10 11 12 @@@
13 14 15 16 @@
17 18 19 20 @

For an incorrect option, an appropriate error message should be displayed.

SOURCE CODE

Page 14
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

ch char main() Stores the choice of the user

i int for(i) in cases ‘A’ Loop counter for two loops in


and ‘B’of switch the given source code
statement

j int for(j) in for(i) of Loop counter for two inner


cases ‘A’ and ‘B’ loops in the given source
of switch code
statement

sc Scanner main() Scanner class object to


invoke the methods of the
Scanner class

Page 15
OUTPUT

1)

2)

3)

Page 16
PROGRAM 7
A Computer showroom has announced festival discounts and the gifts on the purchase of
items, based on the total cost as given below:

TOTAL COST DISCOUNT GIFT

Upto ₹ 35,000 10% A Laptop bag

₹ 35,001 to ₹ 50,000 15% A 16 GB Pen drive

₹ 50,001 to ₹ 70,000 20% A 16 GB Pen drive and a


Laptop bag

Above ₹ 70,000 25% A laptop bag and a 1 TB


External Hard Disk Drive

De ne a class with the following speci cations:

Class name: FestivalBonanza

Member variable: model - model name of the purchased product


total_cost - cost of the purchased product
dis - the amount of discount
net - the net amount to be paid by the customer after availing
the discount
gift - the gift item allotted for the customer

Member methods:

void input( ) - Input the total_cost and the model name of the product (using Scanner
class only)

void discount( ) - Calculate the amount to be paid by the customer as per the rules given
above and also allot the gift item for the customer.

void output( ) - Display the information in the format given below:

Page 17
fi
fi
SOURCE CODE

Page 18
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

model String class Stores the name of the


FestivalBonanza model purchased

gift String class Stores the name of the


FestivalBonanza gift allotted to customer
based on purchase
amount

total_cost double class Stores the value of the


FestivalBonanza purchase amount

dis double class Stores the discount


FestivalBonanza percent availed by
customer based on
purchase amount

net double class Calculates and stores


FestivalBonanza the net amount to be
paid by customer after
discount

obj FestivalBonanza main() object of class


FestivalBonanza

sc Scanner class Scanner class object to


FestivalBonanza invoke the methods of
the Scanner class

Page 19
OUTPUT

1)

2)

3)

4)

Page 20
PROGRAM 8
Write a program to declare a 4 x 5 double dimensional array that stores integer numbers
as given below. Write a program to nd the sum of all odd numbers and the product of all
even numbers.

9 20 14 75 81

191 8 10 55 90

23 41 36 82 57

83 53 20 100 5

SOURCE CODE

Page 21
fi
OUTPUT

VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

arr[ ][ ] int main() Stores given number


values in rows and
columns

oddSum int main() Caluclates and stores


the sum of all the odd
number in the array

evenProduct int main() Calculates and stores


the product of all the
even numbers in array

i int for(i)

j int for(j)

Page 22
PROGRAM 9
Write a program to declare two 3 x 3 double-dimensional arrays of integer type. Accept all
the elements for both the arrays. Create another 3 x 3 double-dimensional integer array,
which stores the sum of each corresponding position. Display the elements of the third
array. For example:

1 2 3 10 11 15 11 13 18

4 5 6 1 4 2 5 9 8
+ =

7 8 9 6 3 9 13 11 18

SOURCE CODE

Page 23
OUTPUT

Page 24
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

arr1[ ][ ] int main() Stores the values of first


array given by user as
input

arr2[ ][ ] int main() Stores the values of


second array given by
user as input

sum[ ][ ] int main() Calculates and stores


the sum of the first and
second arrays

i int for(i) Used as loop counter in


four loops in the main()
method

j int for(j) Used as loop counter for


inner loop within for(i)
loop in four loops in the
main() method

sc Scanner main() Scanner class object to


invoke the methods of
the Scanner class

Page 25
PROGRAM 10
Write a program to declare a two-dimensional array of double data type. The number of
rows and columns are accepted from the user. Also enter the array elements. Display the
sum of the elements of each row separately.

SOURCE CODE

Page 26
OUTPUT

VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

row int main() Stores the number of


rows for the double
dimensional array

col int main() Stores the number of


columns for the double
dimensional array

arr[ ][ ] int main() Has ‘row’ no. of rows


and ‘col’ no. of colums,
takes input from user to
store elements

sum int main() Calculates and stores


the sum of elements in
each row

i int for(i) Used as loop counter for


two loops in main()
method

j int for(j) Used as loop counter for


inner loop within for(i)
loop in two loops in the
main() method

sc Scanner main() Scanner class object to


invoke the methods of
the Scanner class

Page 27
PROGRAM 11
Design a class named ShowRoom with the following descriptions:

Instance variables / Data members:


• name – to store the name of the customer
• mobno – to store the mobile number of the customer
• cost – to store the cost of the items purchased
• dis – to store the discount amount
• amount – to store the amount to be paid after discount

Member methods:
• ShowRoom( ) – constructor to initialize data members
• void input( ) – to input customer’s name, mobile number, cost
• void calculate( ) – to calculate discount on the cost of purchased items, based on the
following criteria:

Discount (in
Cost
percentage %)

Less than or equal to ₹10,000 5%


More than ₹10,000 and less than or equal to ₹20,000 10%
More than ₹20,000 and less than or equal to ₹35,000 15%
More than ₹35,000 20%

• void display( ) - to display the customer’s 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.

Page 28
SOURCE CODE

Page 29
OUTPUT

1)

2)

3)

4)

Page 30
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

name int main() Stores the number of


rows for the double
dimensional array from
user as input

mobno int main() Stores the number of


columns for the double
dimensional array from
user as input

cost int main() Has ‘row’ no. of rows


and ‘col’ no. of colums,
takes input from user to
store elements

dis int main() Calculates and stores


the sum of elements in
each row

amount int for(i) Used as loop counter for


two loops in main()
method

j int for(j) Used as loop counter for


inner loop within for(i)
loop in two loops in the
main() method

sc Scanner class showRoom Scanner class object to


invoke the methods of
the Scanner class

obj showRoom main() Used to call the member


methods of class
showRoom

Page 31
PROGRAM 12
Design a class to overload a function series( ) as follows:
(i) double series (double n) with one double argument and returns the sum of the
following series:

(ii) double series( ) with no argument and returns the sum of the series.

Write a suitable main method to call the other methods.

SOURCE CODE

Page 32
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

sum double series(double n) To calculate and stores


the sum of the first
series

sum double series() To calculate and stores


the sum of the second
series

i int for(i) Loop counter for two


loops within series() and
series(double n)
respectively

obj seriesOverload main() Calls the member


methods of the class
seriesOverload

n double series(double n) Parameter for method


series(double n).
Calculates sum of
elements of series till n.

Page 33
PROGRAM 13
De ne a class Bill that calculates the telephone bill of a consumer with the following
description:
Instance variables / Data members:
• int bno : bill number
• String name : name of the consumer
• int call : no. of calls consumed in a month
• double amt : bill amount to be paid by the person

Member methods:
• Bill( ) – constructor to initialize data members with default initial value
• Bill(...) – parameterized constructor to accept billno., name and no. of calls consumed.
• void Calculate( ) – to calculate the monthly telephone bill for a consumer as per the
following condition:

Units consumed Rate

First 100 calls ₹ 0.60 / call

Next 100 calls ₹ 0.80 / call

Next 100 calls ₹ 1.20 / call

Above 300 calls ₹ 1.50 / call


Fixed monthly rental applicable to all consumers : ₹ 125

• void Display( ) – to display the details

Create two objects in the main( ) method to invoke two constructors. Using the rst object
invoke the other member methods to perform the desired task.

Page 34
fi
fi
SOURCE CODE

Page 35
OUTPUT

VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

bno int class Bill Stores bill no.

name String class Bill Stores the name of the


customer

call int class Bill No. of calls consumed


by the customer

amt double class Bill Calculates and stores


the amount to be paid

obj1 Bill main() Calls the member


methods of the class Bill
and invokes the
parameterised
constructor

obj2 Bill main() Object of the class Bill


calls the non-
parameterised
constructor Bill()

Page 36
PROGRAM 14
Write a program to input 10 numbers in a SDA (Single Dimensional Array) of double data
type. Sort the numbers in ascending order using Bubble Sort technique. Display the
sorted array.

SOURCE CODE

Page 37
OUTPUT

1)

2)

VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

arr[ ] double main() Stores array elements

temp double if() block within Used to swap the values


for(j) loop of the elements at
positions arr[j] and
arr[j+1] when performing
bubble sort

i int for(i) Loop counter for two


loops in the main()
method

j int for(j) Loop counter for the


inner loop for(j) within
the for(i) outer loop in
the main() method

sc bubbleSort class bubbleSort Scanner class object to


invoke the methods of
the Scanner class

Page 38
PROGRAM 15
De ne a class to accept a string and convert it into Uppercase. Display the string by
replacing the vowels by their immediate next consonant.

Sample Input: Indian Citizen


Sample Output: JNDJBN CJTJZFN

SOURCE CODE

OUTPUT

1)

2)

Page 39
fi
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

w String main() Inputs and stores word


from user

s String main() Stores the word ‘w’ after


replacing vowels with
consonants

i int for(i) Loop counter for loop in


the main() method

sc nextVowel class nextVowel Scanner class object to


invoke the methods of
the Scanner class

Page 40
PROGRAM 16
Design a class to overload a function palindrome( ) as follows:
(i) boolean palindrome(int n) – checks whether the number n is a palindrome or
not.

(ii) boolean palindrome(String s) – checks whether the string is a palindrome or not.


Write a suitable main method to call the other methods.

SOURCE CODE

Page 41
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

copy int palindrome(int n) Stores a copy of the


passed parameter ’n'

rev int palindrome(int n) Calculates and stores


the reverse of number n

r int palindrome(int n) Used to find remainder


while performing digit
extraction

n int palindrome(int n) Parameter for method


palindrome(int n)

s String palindrome(String s) Parameter for method


palindrome(String s)

s1 String palindrome(String s) Calculates and stores


the reverse of String s

obj overloadPalindro class Calls the member


me overloadPalindrome methods of the class
overloadPalindrome

Page 42
PROGRAM 17
Write a program to store 5 names in SDA. Display only those names which begin with the
letter ‘a’ or ‘A’ and also ends with the letter ‘a’ or ‘A’.

Sample Input : Mala, Akansha, Priyanka, Amrita.............


Sample Output : Akansha
Amrita

SOURCE CODE

OUTPUT

1)

2)

Page 43
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

arr[ ] String main() Inputs and stores five


names into array

i int for(i) Loop counter for loop


inside main()

sc Scanner class nameA Scanner class object to


invoke the methods of
the Scanner class

Page 44
PROGRAM 18
Write a program to store the following words in an array. Display the words with highest
and lowest number of characters.

Sample Input : KOLKATA, BALI, DELHI, MUMBAI, BENGALORE


Sample Output: The word with highest number of characters is BENGALORE
The word with lowest number of characters is BALI

SOURCE CODE

OUTPUT

Page 45
VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

arr[ ] String main() Stores the given Strings


in array

big String main() Finds and stores the


string with the highest
no. of characters

small String main() Finds and stores the


string with the lowest
no. of characters

i int for(i) Loop counter for one


loop in main() method

Page 46
PROGRAM 19
Write a program to input a sentence. Convert it into upper case. Display the frequency of
characters in alphabetical order.

Sample Input: Indian Citizen


Sample Output:
CHARACTER FREQUENCY
A 1
C 1
D 1
E 1
I 4
N 3
T 1
Z 1

SOURCE CODE

Page 47
OUTPUT

1)

2)

Page 48
PROGRAM 20
Write a menu driven program to display the pattern as per the user’s choice.

Pattern 1 Pattern 2
K 1
KO 22
KOL 333
KOLK 4444
KOLKA 55555
KOLKAT 666666
KOLKATA 7777777

In Pattern 1, the string is accepted from the user and in Pattern 2, the no. of rows is
accepted from the user. For an incorrect option, an appropriate error message should be
displayed.

SOURCE CODE

Page 49
OUTPUT

1)

2)

VARIABLE DESCRIPTION TABLE

Variable Name Data Type Scope Purpose

ch char main() Stores the choice of the


user

sc Scanner class Scanner class object to


switchPattern2 invoke the methods of
the Scanner class

Page 50

You might also like