You are on page 1of 1

CLASS IX

COMPUTER SCIENCE
CHAPTER 5
EXERCISE on if statement
1. What is a selection construct? Explain any 2 selection constructs?
2. Write the Javascript syntax for the following situation
If the amount purchased is
a) more than Rs. 10,500 display “you are entitled 15% discount” otherwise display
“sorry!! No discount”
b) in the range of 10,000-15,000 display “you are entitled 15% discount” otherwise
display “sorry!! No discount”

3. Output
if (hrs > 40) var a=90, b=25;
overtime = (hrs – 40 ) * (rate * 1.5); if (a>50 && a<95)
else {
overtime = 0; a++;
document.write(overtime); b+=a;
}
What is the output if the given values are else
i) hrs = 45, rate = 10 a+50;
ii) hrs = 40, rate = 8 document.write(a + “ “ + b);

i=10; a=3,b=1;
j=10; if(a>0 || b<5)
if(i<100) {
if(j>50) if(a>20)
++i; document.write (“a>20”);
else else
++j; document.write (“a<20”);
document.write ("i = " + i); }
document.write ("j="+ j);

Programs
1. Accept a number from the user. If it is odd print its square. If it is odd print its cube.
2. Accept a character and print if it is a vowel or not.
3. Write a script to input the length of 3 sides of a triangle and check whether the triangle is
a right triangle or not
4. An employee’s salary is Rs. 4500. If he has been working for more than 5 years in the
organisation, he gets a bonus of Rs. 1500 otherwise he gets a bonus of Rs. 750. What is
his total salary. (accept years of experience)
5. A student appears in 3 tests T1, T2 and T3. Calculate his average marks and print the
grade accordingly:

Average_marks Grade
>90 and <=100 A1
>80 and <=90 A2
>70 and <=80 B1
>60 and <=70 B2
>=50 and <=60 C1
If the student secures below 50 then display “work harder” in red colour.

You might also like