questions
questions
Write a program to assign values to the variables length and breadth and
print if it is a square or rectangle.
PROGRAM 2
Write a program to input the values to the variables length and breadth and
print if it’s a square or rectangle
PROGRAM 3
PROGRAM 4:
PROGRAM 5
PROGRAM 6:
Name: Ritthul Venkatesh
UID:
ISC 2025
PROGRAM 7:
Member Functions:
No. of calls
Rate
1-100
₹500 (base)
101-200
₹1.00 per call above 100 + base
201-300
₹1.20 per call above 200 + base
>300
₹1.50 per call above 300 + base
PROGRAM 8:
#***#
* *
* *
* *
#***#
PROGRAM 9:
Sum=1+x2/1!+x3/2!+x5/3!+…….x2n-1/n!
A class Seriessum has been defined to calculate sum of the above series.
Define the class as given:
int n, x
double sum
Member Functions:
PROGRAM 10:
A magic number is a number in which the eventual sum of digits of the
number is equal to 1.
Example: 172 = 1+7+2 = 10 = 1+0 = 1
Member Functions:
void isMagic() Checks if the given number is a magic number or not and
displays and appropriate message.
PROGRAM 11:
Palprime numbers are palindromic prime numbers i.e. the prime numbers
that are palindrome also.
First palprime number is 2 digit (2-d) number and it is 11. There is only one
palprime which is 2 digits long.
To generate a 3 digit (3-d) palprime number there are many methods. One
method is where one just needs to insert a 1-d palprime number in between
11 and then test for its primeness.
This way only two palprimes are generated (by inserting 3 and 5 and
between 11)131 and 151.
(insertion of 7 in 11 does not yield a prime number)
You need to write the method GenPalPrime for the following class that
generates palprimes using the method mentioned here:
class PalPrime
{
public static void GenPalPrime (int n)
{/* the passed number n tells the number of digits in the palprime to be
generated. Acceptable values for n are 2-5*/
}
}
Name: Ritthul Venkatesh
UID:
ISC 2025
The 5-d primes may be generated by inserting 3-d palprimes in 11 e.g.
insertion of 131, 383, 797, yields these palprime numbers : 11311, 13831,
17971
PROGRAM 12:
Brun's Constant. Twin primes are the prime numbers with a difference of 2
e.g. (3,5)
(5,7), (11, 13), (17,19), (29,31)......etc
The sum of reciprocals of the twin primes converges to a sum known as a
Brun's
Constant i.e.,
The class Primes below contains methods which help you to work with twin
primes and
Bruns's constant. Study the class and then answer the questions that follow:
public class Primes {
public Boolean IsPrime( int n)
{
/* returns true if n is a prime number, false otherwise*/
// assume n >1
}
public void twin Primes( int lim)
{ /* prints out twin primes below lim. Each pair is printed on a separate line
within
brackets e. g. (3, 5)
*/
public double BrunConstant(int lim)
{ /* calculates and returns Brun's constant below lim */
Define all the methods of the class Primes given above.
Define method main () that obtains the limit value and prints the Brun's
constant
accordingly.
Sample Input Output
Enter limit
13
(1/3 +1/5)+(1/5 +1/7) +(1/11 +1/13)
Brun's constant below limits 13 is: 1.0440226793289185
PROGRAM 13:
1. As per Number Theory there are many types of special numbers. Some
of these special number types are listed below.
Name: Ritthul Venkatesh
UID:
ISC 2025
Armstrong or Narcisstic Numbers. An Armstrong number (also known as
Narcisstic number) is the one whose individual digits cube-sum is equal to
the number itself.
Eg. 407 is an Armstrong number because
407 = 43 + 03 + 73
number (long)
Member Functions:
PROGRAM 14:
Design a class to represent a bank account
Class name-account
Name of the depositor
Name: Ritthul Venkatesh
UID:
ISC 2025
Type of account
Account number
Balance amount in account
Member methods
To assign an initial values
To deposit amount
To withdraw an amount after checking balance
Write the main method create an object ,constructor to call the function
PROGRAM 15:
A class Mystring has been defined for the following methods/functions:
Class name: Mystring
Data members / instance variables Str[]:to store the string
Len: length of the given string from the input Member functions/ data
members
My string(): constructor
Void readsting(): reads the given string from the input
Int code (int index): returns ACII code for the character at that position.
PROGRAM 16:
Design a class String function to perform various operations on strings
without using a built-in function except for finding the length of the string.
Some of the member function/data members are given below
Class name: Stringfun
Data Members/ instance variables Str: to store the string
Member functions /methods Void input (): to accept the string
Void words (): to find and display number of words, numbers of vowels and
number of uppercase characters in the string.
Void frequency: to display the frequency of each character within in the
string.
Specify the class Stringfun giving the details of the function void input (),
void words() and void frequency() With the main function.
PROGRAM 17:
A class stringop is designed to handle string related operations. Some
members of the class are given below Data member
Data members
Txt: to store the store the given string up to of maximum length 100 Member
function/methods
Stringop(): constructor
Void readstring ():to accept the string
Char caseconvert (int, int): to convert the letter to another case
Name: Ritthul Venkatesh
UID:
ISC 2025
Void circular code (): to decode the string by replacing each letter by
converting it to the opposite case and then by the next character in a
circular way. Hence “AbZ” will be decode a “bCa”.
Specify the class by giving the details of all the functions including main ()
PROGRAM 18:
A class rearrange has been defined to insert an element and to delete an
element from the array. Some of the data members of the class are given
below
Class name: Rearrange
Data members/instance variables A []: integer array type array
N :size of an array
Pos1:position of insertion(integer) Pos2: position of deletion (integer) Item:
item to be inserted(integer) Member function/methods
Void enter ():to enter size, array elements and to display the array elements
entered
Void insert():to accept the element to be inserted posiition of insertion and to
insert the element(item) that position of insertion
Void disp1():to display the array after the insertion of element
Void disp2():to display the array after the element has been deleted
Void remove ():to accept the position of the element to be deleted and
delete the element item at the position of deletion
Specify the class rearrange giving the details of all the functions and main
functions
PROGRAM 19:
A class sort contains an array of 50 integers. Some of the member functions /
data members are given below
Class name: sort
Data member /instance variables Arr []: integers
Item: item to be searched Member functions/methods
Void inputdata (): to input 50 integers (no duplicate numbers to be inputted)
Void bubsort (): to sort the array in ascending order using the bubble sort
technique and to display the sorted list
Void binsearch (): to input item and search for it using binary search
technique ; if found to print the item searched and its position in the sorted
list other wise print the appropriate message
Specify the class sort giving the details of the function and their main
function.
PROGRAM 20:
A transpose of an array is obtained by interchanging the elements and rows
and columns. A class Transarray contains a two-dimensional integer array of
order(n*m). the maximum value possible for both m and n is 20 .design a
Name: Ritthul Venkatesh
UID:
ISC 2025
class Transarray to find the transpose of a given matrix. the details of the
member of the class are given below:
Class name: Transarray tra
Arr[][]:to store the matrix elements
M: integer to store the no of rows
N: integer to store the number of columns Member function/methods
Transarray ():default constructor
Transarray (int mm, int nn): to initialize the size of the constructor M=mm,
N=nn Void fillarray (): to enter the elements of the matrix
Void transpose (transarray A):to find the transpose of the given matrix
Voiddisparray (): to display the array in the matrix form
Specify the class transarray giving the details of the constructor and other
functions Write the main function to execute the program.