Final Term Worksheet Comp
Final Term Worksheet Comp
NATIONAL
GOPALAN
Moth
functions,
Methods 63.0
BENGALURU
WHITIEFIELD,
Mathematical
Library d=Math.ceil(Mat
functions:
44$
5.Mathematical 22 -1408
-Ts
k)Math.round(-18.51)
Math.min(13,14)
h)Math.max(22,
a=Math.max(a%100,a/100
--2/.0 i)Math.min(Math.floor(2.9),2.5)2-0
following different
1Math.round(Math.abs(-0.5))
i) System.out.print
D=
63.0
following -7
f)Math.max(-17,-19)
CH
.0
a)
/.0
Matd) h1.Math.round(0.5)
Math.ceil(-4.2) fe)loor(-20.
c)Math.pow(2,0) O
8.
10)
g)Math.ceil(7.8)
3.2
)Math.sqrt(10.24)
a 4the
m)Math.abs(99.4) for
used System.out.println("A="+
4 of a)
Math.sqrt();
doube
Aoubec)Math.ceil();
doubk
b)Math.pow();
d)Math.floor();
odse e)Math.round():
it double
b)Math.abs(-4) type
the is
for return that
-62.4;
output class
the a=948;int
:IX
CLASS the C=
:NAME Give 2.Predict 5.double
3.Name
1. 4.int
6.What will be the output of following code?
double b= -15.6;
double a=Math.round(Math.abs(b));
System.out.printin("a="+a); ar l6
7.Give output for the following segment :
double x=2.9,y=2.5;
System.out.printin(Math.min(Math.floor(x), y));
System.out.printin(Math.max(Math.ceil(x),y));
8.What are the final values stored in variable x and y below?
double a= -6.35;
double b=14.74;
double X=Math.abs(Math.ceil(a)); 6
double y=Math.round(Math.max(a,b)); 15.0
9.What will be the final values be stored in variables
when executed?
double a=-3.5;
double b= -25.0;
double p=Math.abs(Math.floor(a)); 40
double q=Math.sqrt(Math.abs(b)); 50
10.What will be the value of num given in following
statements
int min=1,max=10;
int range=max-min+1;
int num=(int)(range*Math.random()+min);
11. Write the equivalent java
statements for the following ,by using the
functions: mathematical
a) Print the positive value of -999.
b)Store the value -3375 in a variable and print its
cube root. in x-3575
c) Store the value 999.99 in a
variable and convert it into its closest integer that ic
greater than or equal to 999.99.
Hint:Triangle2/Write Smallest
numberSampl
34e Sample Hinsmal
t: lest 1.Write Pg12.
(a) (c) (b) (entered
a) 3.Write noWrite
TakedisplayBiology. 4.In Cube Square
Absolute h Use
Random Input: of a
examination, an
PROGRAMS163(Q4.
.3)
by a = by a Output: Mat h.min() thpre ogram
Physics, the of program Vp2+ takingprogram mat hematical
Write the root value the 87, three
marks numbers b² it
number of user: Greatest 65, in. n
Chenmistry. in
program a the of to perpendicular and
34numbers. r(x).at.
in Java
input
S.oJavaph{ia-375;
have
you
the to equation
rounded-off between number
number to Number Math.max( input
three
the
and in a calculate for
Java number
0 and 87 followingthe
Biology form. to
appeared (zero) )
and base and numbers
marks calculate and evaluate as
display
for 1 inputs.
as the three (one). and
inputs. average the the
subjects display
results hypotenuse
mark i.e. based
greatest
obtainedPhysics, of
on a
the Right-Angled
Chemi
and stry and
number the
finally
and
to calculate theradius of acircle byusing the formula:
5.You want
Area= (22/7) * r2; where r= radius of a circle
Hence the radius can be calculated as:
r=V(7 * area) /22)
as
Write a program in Java to calculate and display the radius of a circle by taking area
an input.
6.Program to compute the perimeter andare of a triangle with its three sides given as
a,b,c using the following formula
Perimeter=a+b+c
Use Heron's fornula with
sides ab and c
a+6c
Area=
/a(s- a)(s b){8 c)
7.Program to calculate and display the final
velocity by taking initial
,acceleration and the distance covered as input.
V2=u2+2as
where usinitial velocity
velocity
a=acceleration and the distance
covered as inputs.
GOPALAN WUTEFIEL),
NATIONAL BLNGALURU
SCHOOl
NAME :
CLASS :1X CH 5.0perators in java
346 4356
i) x+=x¢+ + ttx +X; when x=4; a0
i)p+=(-p+5)*(p++)*(r/2) ;when p=7and r=11
iv) q*=5+(--a)*(g++)+10;when q-9 7 370
System.out.println("ODD");
Syitm,outprit "EvtN
n(tye ODD
programming Interface
1.What is mean by a package?Name any two Java application
packages.
2.What are delimiters?
a)Math.sqt(36): Sye
b)int a;b;c; Syree
c)int a==b+c; Syrtt
operation should be division. Llca
d)Multiplication operator is used when the
comments and write its name?
5.Which of the followings are valid
i) /* comment */ vai, Mati line
in)/*comment avai
ii)//comment vaa,sigleine
iv)*/comment*/
class
6.Name the method of scanner
from the standard input device. netLt)
a) is used to input an integer data
standard input device. etShig nat)
b)is used to input a string datafrom the
standard input device. nent ). chrt
clis used to input a character data from the
7.Write line of code that
named
objectsean
a) Creates ascannerSeannan scan and read double value in dblvariable
<new Seannen CSytindn;
program
bl toinclude allclasses present in the java .util package into your
what is the difference between the scanner class element next() and nextLine()?
9.Write a program to computethe Time of period (T) of.a simple pendulum
following formula:
Input the value of L(Length of pendulum )and g
T=2n//g
Scannerclass.
leravity
methods ,to read and displav st
10. Write aprogram in java ,using the scanner
following details.
Name-as a string data type.
RollNumber -as an integer data type
Marks in 5 subjects -as a float data type
Compute and display percentage of marks.
1Write a program by using class 'Employee' to accept Basic pay of an
employee.Calculate the allowance/deduction as given below.Finally find and print the
Gross and Net pay.
Dearness Allowance(DA) :30% of Basic pay
House Rent Allowance(HRA) :15%of Basic pay
Provident Fund(PF) :12.5% of Basic pay
Gross Pay =Basicpay+DA+HRA
Net Pay= Gross Pay-PF
**** k *
Class
SCHO)OL
NATIONAL
GOPALANWWPLD BENGALUR
S
an
NAME:
CLASSX CH9.conditional constructs in java |en
b)iflp>=4750)
k-p*s/100;
else
k-p*10/100;
c) ifla>b)
if(a>c)
ga;
else
g=c;
if(b>c)
g-b;
else
g-C;
in
Taxable income(TI)
* 10%
than or cqual to (TI- 1,60,000)
2.50,000 and less
More than
S,00,000 20% +
(TI -5,00.000) *
or equal to
5,00,000 and less than 34,000
More than
10,00,000
30% +
(TI - 10,00,000)*
94,000
Morethan 10,00,000
income of a person. If the age is
the name, age and taxable age is less than
Write a progranto inputdisplay the message "Wrong Category". If the with the
more than 60 years then compute and display the income tax payable along
or equal to 60 yearsthen table given abOve. in
name of tax payer, as per the certain sumof money under "Term Deposit' scheme
6.An employee wants to depositprovided the tariff of the scheme, which is given below:
Syndicate Bank. The bank has
Rate of Interest
No. of Days
5.5%
Up to 180 days
Write a program to calculate the maturity amounttaking the sum and number of days
as inputs.
7.A company announces revised Dearness Allowance (DA) and Special Allowances
(SA)for their employees as per the tariff given below:
Basic Dearness Allowance (DA) Special Allowance (SA)
Up to ?10,000 10% 5%
10,001 -20,000 12%
8%
{ 20,001 -30,000
15%
10%
730,001 and above 20%
12%
Write aprogram to accept nameand 3Basic Salary (3S) of an employee. Calculate and
display gross salary.
Gross Salary =Basic + Dearness Allowance +Spccial Allowance
Print the information in the given format:
Name Basic DA Spl. Allowance Gross Salary
XXX XXX XXX XXX
8.Using a switch case statemcnt, write a menu driven program to convert a given
temperature from Fahrenheit to Celsius and vice-versa.
For an incorrect choice, an appropriate message should be displayed.
Hint: c = 5/9*(f-32) and f=1.8*c+32
9.The volume of solids, viz. cuboid, cylinder and cone can be calculated by the
formula:
Volume of a cuboid (v = 1*b*h)
Volume of a cylinder (v = *r*h)
Volume of a cone (v =(1/3)*n*r*h)
Using a switch case statement,write a program to find the volume of different solids
by taking suitable variables and data types.
10.The Simple Interest (SI) and Conmpound Interest (CI) of asum (P) for a given time
(T) and rate (R) can be calculated as:
(a) SI =(p *r*t)/ 100 (b) CI =P* ((1 +(R/100))" - 1)
Write a program to input sum, rate, time and type of Interest ('S' for Simple
and 'C' for Compound Interest). Calculate and display the sum Interest
11. Write amenu driven program to calculate: and the interest earned.
Area of acircle = p*r2, where p (22/7) [15]
Area ofa square = side*side
*****
GOPALAN NATONAL SCHOOL
Name: WORKSHEET
Class : CH:NESTED FOR LOOP(JUMP STATEMENTS)
a) int x,y;
for(x=1;x<=5;x++)
for(y=1;y<5;y++)
if(x==4)
break;
System.out.print(y):
System.out.println(0;
b. int i,j;
for(i=10;i>=5;i--)
forlj=5;j<=i;j++)
if(i*j<40)
continue;
System.out.print(j):
System.out.printin);
c. int i,j;
for(i=1;i<=5;i++)
for(j=1;j<=3;j++)
if(i%2==0)
continue;
System.out.print(i*it" ");
d.int i,j: 4
for(i=1;i<-5;i++) 8
12
{
forlj=1;j<=3j++)
System.out.prinln(ii):
if(i==)
break;
}
e. for(int i=l;i<=5;i++)
for(int j=1;j<-3;j++)
System.out. print(i"j);
if(i>2)
break;
System.out.print("*****);
}
f. for(int i=1;i<=5;i++)
for(int j=1;j<-i;jt+)
if(i==4) jl 23 123
break; 5 s123H5
System.out.print(j);
System.out.println ();
8. for(int i=1;i<=5;i++)
for(int j=1;j<-3;j++)
if(i"j>=10)
continue;
System.out.print(i*j+" );
executed?
V)What
II)Study h.
or(int
;i<5;it+) ctr=0;
int
System.out.printin(number);
=2)for(intnumber-(int)Math.random()*10); W)Anal
i=3;i<=4;it+)
for(inta) yse
j=0;j<2;j++)
int for(int
i=0;i<3;i++)
for(int i) i) it(i=2) for(int
is b) sampleMethod()
public for(int
System. the j-1;j<«3;j++)
for(icontinue,
nt
void out.printin("WIN");
the Whata)How System.out.println(""):j=2;j<i;j++) System.out.print(i°j ";
"
final the i=
many
method Write How 1,
is given ix=5;+)
value the themany
times and output program
of
range times
ctr the answer
of of
when possible inner does segment
the the
the
the loop given program inner
and
iteration values does
questions:segment loop answer
stored
execute?
process wil the
in execute?.
the
following
given
variable
below questions
number?