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

JH EcampusUpload SubjectNote Grade 11 PROGRAMING ASSIGNMENT 3 Funcnctions

This document outlines an assignment for Grade 11 Computer Science focusing on Object-Oriented Programming (OOP) concepts. It includes various programming tasks such as checking for prime numbers, palindrome numbers, calculating electricity bills, and designing classes for different functionalities. Each task requires the use of specific functions and methods, with an emphasis on input, processing, and output, along with the creation of classes and constructors.
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)
45 views3 pages

JH EcampusUpload SubjectNote Grade 11 PROGRAMING ASSIGNMENT 3 Funcnctions

This document outlines an assignment for Grade 11 Computer Science focusing on Object-Oriented Programming (OOP) concepts. It includes various programming tasks such as checking for prime numbers, palindrome numbers, calculating electricity bills, and designing classes for different functionalities. Each task requires the use of specific functions and methods, with an emphasis on input, processing, and output, along with the creation of classes and constructors.
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

COMPUTER SCIENCE – GRADE 11

PROGRAMS - FUNCTIONS

Assignment 3

DATE OF SUBMISSION : 1st September 2025

Note : Where ever input is asked use Scanner class.


Solve the following using (OOP concept i.e. each class should have constructor, separate
method/function for input-process-output and main method to create the object of the
class and call other methods. Write program in the journal with variable description
and output.

1. Write a program to accept a number and check whether the number is prime or not.
Use function name as check(int n). The function returns 1, if the number is prime
or otherwise returns 0
2. Write a program to accept a number and check whether the number is palindrome
or not. Use function name as palin(int n). The function returns true, if the number
is palindrome or otherwise it returns false.
3. Write a program to accept a number and check if the number is prime palindrome
or not. You can specify the function int check(int n ) to check if, the number is
prime and int palin(int n) to return reverse of the number. Specify function
display() to check if, the number entered is prime and palindrome calling
respective functions.
4. Write a program to accept two numbers and check whether they are twin prime or
not. Use the function name as prime(int n). The function prime returns number of
factors the number has. Twin prime is a consecutive prime with difference of 2.
Eg. 3,5
5,7
11,13

5. Write a program to calculate the monthly electricity bill of a consumer according


to the units consumed. The tariff is given below:

Write different functions for input- process and output. Also define main function to call other
functions.
6. Write a menu driven program using a method boolean buzz(int n ) and int Composite(
int n ) to perform following tasks:

a. Accept a number from the user and check whether the number is “Buzz
number” or not . A Buzz Number is number which either ends with 7 or
is divisible by 7.
b. Accept a number from the user and check whether the number is composite
number or not.

7. Design a class for menu driven program to calculate area of the scalene triangle,
area of trapezium and area of rhombus. Use following function prototypes and
formulas.

8. Design a class SumSeries for menu driven program to calculate sum of the
following series.
a. S = 1 + x/1!+x3/2!+x5/3!+……..+ xn/n-2!
b. S = 1 + ( 1 * 2 ) + (1 * 2 * 3) + (1 * 2 * 3* 4)+…………..(1 * 2* 3……* n)
9. Write a program to input a number and check if the number is Pronic Number or

not. Use a function pronic(int n) to check n and return 1 if the number is


pronic, else return 0.
Hint: Pronic number is the number which is the product of two consecutive
integers) Examples 12 = 3*4
20 = 4 * 5

9. Write a program to print all Armstrong numbers in the range m to n. Define function
Arm(int n) which returns true if number is Armstrong else returns false.
Hint: Armstrong number is the number where sum of the cube of each digit of a
number equals the number it self.

10. Write a program to print all the prime numbers in a range m to n where m < n
using function check(int n). The function returns 1, if the number is prime or
otherwise returns 0.
11. Write a program to print all the prime palindrome numbers in a range m to n where
m < n using function Boolean check(int n) and Boolean palin(int n).

12. Design a class calculator that calculates only with integers.


Some of the function/methods of the class calculator are shown below.
Class Name : Calculator
Data Members :
Variables : result
Member functions :
Calculator() : constructor
Enterfirst(int x) : to enter the first number (first operand)
Showresult() :to display result
Int add(int x) : to add the argument to the result
Int sub(int x) :to subtract the argument from the result

13. Design a class student having following description:


Data members/Instance variables
String name – Store the name of the student
int roll – to store the roll no. of the student
int p,c,b – to store his physics , chemistry and biology marks
double S – to store his science marks (average of physics , chemistry and biology)
member functions :
input ( ) – to input the details
calculate ( ) – to calculate the science marks
display ( ) – to display the details in the following formate:
Name Roll No. Science Marks
------------------------ ---------------------------- ----------------------------
Also write the main method to create an object and call the above methods.
14. Write a menu drive program using the overloaded function called area( ) to calculate
area of
a. Circle 𝜋𝑟 2 where 𝜋 = 3.14
b. Square side * side
c. Rectangle length * breadth

15. Write a class with the name Calculate using function named volume which is that
computes the volume of a cube , sphere and cuboid using function overloading.
Volume of cube = s * s * s
Volume of a sphere = 4/3*22/7 *r*r*r
Volume of cuboid = l * b * b

******************************************************************

You might also like