Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Computer Applications

Programming Assignment / Project Work

1
Instructions:
• Students you are supposed to make a file for Programming
Assignment, attached with loosed ruled sheet.
• Programs should be neatly hand written or typed. If printout is
attached, it must be in A4 sheets.
• Do not continue the next program on the same sheet where
previous program has ended. Each new program should begin
on the new separate sheet.
• Program should be numbered as Program 1, Program 2.
• Every program must have a proper documentation, it must begin
with single line comment.
• Every program must have variable description at the end of the
program.
• File cover page must be neatly hand written or typed with
Name, class-section, admission code & subject.

2
If-Else-if
Question 1
A shopkeeper offers “Summer Discount” to his customers according
to the goods purchased as per the following criteria:

Purchased Amount(Amt) Discount(D)


Amt <= 1000 5%
Amt >1000 and Amt <= 2000 10%
Amt> 2000 and Amt< = 5000 15%
Amt>5000 20%

Write a program to input customer name and purchased amount to


calculate the discount rate as per the give conditions and the
net amount to be paid by the customer.
Discount = ( discount rate /100) * amount of purchase
Net amount = amount of purchase – discount
Display the details in the following format:
Name of the customer……
Purchased amount ………
Discount offered …….
Net amount to be paid……

Question 2
Design a class Railway Ticket to perform the following operations:
Data Members:
String name to store the name of the customer
String coach to store the type of coach customer wants to
travel
long mobileNo to store customer’s mobile number
int amt to store the amount of ticket.
int totalAmt to store the amount to be paid after updating the
original amount.

3
Member methods:
void accept ( ) to take input for name, coach, mobile number
and amount.
void( ) to update the amount as per the coach selected.

Extra amount to be added in the amount as follow:


Type of Coaches Amount
First_AC 900
Second_AC 650
Third_AC 550
Write a main method to create an object of the class and call the
above member methods.

Question 3.
Write a program to input a character and check whether it is vowel
or not. If the character is vowel then print a message “ the input
character is a vowel” else print “ the input character is not a vowel”.

4
Function-Overloading

Question 4
Design a class to overload a function Area () as follows:
i) double Area ( double R)- with radius(R) as an argument,
returns the area of circle using the formula:
area_circle = (22/7) * r * r
ii) int Area( int S)- with side(S) as the arguments, returns the
area of a square using formula:
area_square= side * side

iii) double Area ( double L, double B)-with length(L), breath(B)


as the arguments, returns the area of rectangle using
formula: area_ rectangle = length * breadth

Question 5
Design a class to overload a function Area () as follows:
i) double area (double a, double b, double c)- with three double
arguments, returns the area of a scalene triangle using the
formula:
area_ triangle = √s(s-a) (s-b) (s-c)
where s= (a+b+c)/2
ii) double area (int a, int b, int height)- with three arguments,
returns the area of a trapezium formula:
area_ trapeze= 1/2 * height*(a+b)

iii) double area ( double L1, double L2)-with two double


arguments, returns the area of a rhombus using
formula: area_ rhombs = 1/2 (diagonal L1* diagonal L2)

5
Switch-Case Menu Driven

Question 6
Make a menu driven program using switch statement which will
print the following series.
1 -Prime -To print all the prime numbers between 1 to 100
(A number is a prime when divisible by 1 & a number itself
Example 1,2, 3, 5…. etc)
2 -Factorials-To print the factorials of 1*2*3*4*…….*x.

Question 7
Using switch statement, Write a menu driven program:
a) To check and display whether a number given by the user is a
perfect number or not.
A perfect number is a number which is equal to the sum of
its divisors.
Example
Input 6
Output: 6=1+2+3.
b) To input a number and check whether the number entered is a
BUZZ number or not.
A BUZZ number is the number which either ends with 7 or is
divisible by 7.
Example:
Input: 21
Output: it is a buzz number

6
For -Loops

Question 8
Write a program to input a number to check whether it is a Pronic
number or not, if it is a Pronic number print a message “It is a Pronic
number” else print “It is not a Pronic number”.
A Pronic number is the number which is the product of two
consecutive integers.
Examples:
6=2*3
12= 3*4

Question 9
Write a program to generate the sum of the following series:
i) double Sum_Series1(double a, int n) with two double
arguments and returns the sum of the series:
sum=12/a+22/a+32/a+…..n2/a up to n terms
ii) double Sum_Series2(double x, int n) with double and int
arguments and returns the sum of the series
sum= x1 + x2 + x3 + x4 + x5 + ……..xn
iii) double Sum_Series3 (double n) with one double argument and
returns the sum of the series:
sum =1/2+3/4+5/6------------------n/n+1

7
Question 10.
Write a program to generate and print Letters from A to Z with their
Unicode codes.

Letters Unicode
A 65
B 66
C 67
. .
. .
. .
Z 90

Contd….

8
While -Loops

Question 11.
A tech number has even number of digits. If the number is split in two
halves, then the square of sum of these halves is equal to the number
itself. Write a program to input a four digit number and check whether
it is tech number or not.
Example:
N=3025
the square of sum of the halves of 3025= 30 + 25
= (55)2
= 3025

Question 12.
Write a program to accept a number and check and display whether it
is a spy number or not. A number is spy if the sum of its digits equals
the product of its digits
Example:
1124 Sum of its digits =1+1+2+4 = 8
Product of its digits=1*1*2*4 = 8

Question 13.
A special two-digit number is such that when the sum of its digits is added
to the product of its digits, the result is equal to the original two-digit
number. Write a program to input two digit number and check whether it
is special number or not and display the appropriate message.
Example
59
Sum of its digits = 5 + 9 =14
Product of its digits = 5 * 9 = 45
Add sum + product = 14 + 45 =59

9
Nested For -Loops

Question 14.
Write a program to display the following patterns:
a. 1
22
333
4444
55555

b. 1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

Question 15.
Write a program to display the following patterns:
a.
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
b.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

==============

10

You might also like