# Other School Class 8 First Term 2018

## Section A [33 Marks]

Q1. Write an algorithm and draw a flowchart to assign Team India and Team England’s total score in the last ODI.
If their average score lies in the range 250 – 300, then print the message “EXCELLENT SCORE”, otherwise print the message “SCORE IS OKAY”.
Algorithm:
1. READ INDIA AND ENGLAND SCORE IN A AND B RESPECTIVELY.
2. AVG = (A + B) / 2
3. IF AVG >= 250 AND AVG <= 300 THEN PRINT “EXCELLENT SCORE” ELSE PRINT “SCORE IS OKAY”
Flowchart:

a) Where is an operating system usually stored?
The operating system is usually stored on the hard disk of a computer.
b) Mention one purpose of BIOS.
The BIOS is used to load the operating system program from the hard disk into RAM.
c) Write 3 differences between char literal and String literal.
(i) A char literal is a primitive data type, whereas a String literal is a composite data type.
(ii) A char literal is enclosed in single quotes, whereas a String literal is enclosed in double quotes.
(iii) A char literal occupies 2 bytes of storage, whereas a String literal has no fixed storage.
d) Enlist 3 features of Java bytecode.
(i) It is platform independent.
(ii) It is generated after compiling the Java source code.
(iii) It is interpreted by the JVM.

Q3. Give the output:
(i) Math.pow(2, 4)
16.0
(ii) int y = 0, z = 10;
double x = 8;
a) if(x < 8 || y > -1)
System.out.println((int)x / z);
0
b) System.out.println(“z + y = ” + z + y);
z + y = 100
c) System.out.println(“z + x = ” + (z + x));
z + x = 18.0

Q4. Evaluate the given expression when p = -7, r = 5, s = 3, t = 3.
p * s % r + s – r * p
= (-7) * 3 % 5 + 3 – 5 * (-7)
= -21 % 5 + 3 – (-35)
= -1 + 3 + 35
= 2 + 35
= 37.

Q5. Give one word/term for each of the following:
a) The type of operating system used in robots. (Real time OS)
b) The symbols that should not cross each other. (Arrow lines)
c) (int) x / y; the underlined process is termed as? (Type casting)
d) Symbol that represents ‘flow’ in a flowchart. (Flow lines)
e) The kind of operator == is? (Relational operator)
f) !(!(6 == 6)) will return? (true)
g) JVM is an interpreter/compiler? (Interpreter)
h) The storage capacity of short integer is? (16 bits or 2 bytes)
i) The default char value is? (‘\u0000’)
j) Combination of variables and constants and operators. (Expression)

Q6. Rewrite the given expression in Java:
(-2b + √(b3) + yz) / (4c)
(-2 * b + Math.sqrt(b * b * b) + y * z) / (4 * c)

## Section B [52 Marks]

Q7. Write a class Employee with the given specifications:
Function/Method Name:
calculate()
Data Members:
basicSal
Calculate and display the Net Salary per month of the employee after all the allowances are added and deductions (income tax and PF) are made.
Dearness Allowance = 30% of basic salary.
House Rent Allowance = 15% of basic salary.
PF = 9% of basic salary.
Income Tax = 10% of gross salary, if gross salary exceeds Rs. 30,000 per month. Otherwise, Income Tax is NIL.
Print Gross Salary and Net Salary with proper message.

``````class Employee{
void calculate(){
double basicSal = 45000.0;
double da = 30.0 / 100 * basicSal;
double hra = 15.0 / 100 * basicSal;
double pf = 9.0 / 100 * basicSal;
double gross = basicSal + da + hra - pf;
double it = 0.0;
double net = 0.0;
System.out.println("Gross salary = Rs. " + gross);
if(gross > 30000)
it = 10.0 / 100 * gross;
net = gross - it;
System.out.println("Net salary = Rs. " + net);
}
}``````

Q8. Assign an integer to a variable x. Variable y is the quarter (one-fourth) of x and variable z is the triple of the sum of x and y. Write a program to print the product, sum and average of x, y, and z with proper message. Also print the result of the following expression: (x2 + y2) / z2.

``````class Solve{
void find(){
int x = 5;
double y = 1.0 / 4 * x;
double z = 3 * (x + y);
double s = (x * x + y * y) / (z * z);
System.out.println("Quarter of x = " + y);
System.out.println("Triple of sum of x and y = " + z);
System.out.println("Result of the expression = " + s);
}
}``````

Q9. Write a program in Java to assign the distance traveled by a bus in 4 hours. If the speed of the bus is above 65 kmph, then print the comment “High speed”. Otherwise print the comment “Moderate speed”.

Display the output in the given format:
All Bengal Transport Corporation

Speed:- ________ kmph
Comment: ____________

``````class Distance{
void find(){
double d = 270.0;
int t = 4;
double s = d / t;
System.out.println("All Bengal Transport Corporation");
System.out.println("Speed:- " + s + " kmph");
System.out.print("Comment: ");
if(s > 65)
System.out.println("High speed");
else
System.out.println("Moderate speed");
}
}``````

Q10. Design a class ProLoss to assign the cost price of an article, the selling price of which is Rs. 8000. Print profit and profit %, or loss and loss % or the message “No profit no loss”.

``````class ProLoss{
void display(){
double cp = 12000;
double sp = 8000;
if(cp > sp){
double loss = cp - sp;
double lp = loss / cp * 100;
System.out.println("Loss = Rs. " + loss);
System.out.println("Loss % = " + lp);
}
else if(cp < sp){
double profit = cp - sp;
double pp = profit / cp * 100;
System.out.println("Profit = Rs. " + profit);
System.out.println("Profit % = " + pp);
}
else
System.out.println("No profit no loss");
}
}``````

This site uses Akismet to reduce spam. Learn how your comment data is processed.