Grade 9 Journal Assignments Final
Grade 9 Journal Assignments Final
Assignment 1
Operators in Java
1. What is the result stored in x, after evaluating the following expression :
int x=5; x=x++*2+3*--x;
2. What is the output of the following program segment?
char x=’A’; int m;
m = (x==’a’) ? ’A’ : ’a’;
System.out.println(“m=”+m);
3. Write an expression in Java for
4. Give the output of the following expression: a+= a++ + ++a + --a + a--; when a=7;
5. Rewrite the following using ternary operator:
if(x%2==0)
System.out.println(“Even”);
else
System.out.println(“Odd”);
Assignment 2
Programs using Assignment statements.
1. To assign the length, breadth and height of a cuboid and find its volume.
2. To assign two unequal numbers. Display the numbers after swapping their values in
the variables.
3. To calculate the Simple Interest on Rs.10000 at annual interest of 18% for 20 years.
Assignment 3
Programs based on Input through parameters.
1. To accept 5 digit integer, and from it extract the first digit and store it into a variable f
and extract the last digit into a variable e, and display both these digits.
2. To accept the salary of an employee and add 15% increment to it.
3. To input the temperature in degrees Fahrenheit and convert to degree centigrade.
( )
Assignment 4
Programs based on Input through Scanner class.
1. To input name, and basic salary. Calculate and display the following :
HRA @ 15% of basic salary.
DA @ 70% of basic salary.
TA @ 2% of basic salary.
PF @ 10% of basic salary.
Gross_salary = basic + HRA + DA + TA
Net_salary = gross - PF
2. To input item name, rate and quantity sold. Calculate the amount (rate * quantity).
Add 12.5% as VAT and display the net bill.
3. To input values representing time duration in hours, minutes and seconds and then
prints the equivalent total number of seconds. Eg. 1 hour, 28 minutes, 42 seconds is
equivalent to 5322 seconds.
Assignment 5
Programs based on Mathematical methods.
1. To input 3 sides of a triangle and find the area using Heron’s formula.
√ ( )( )( )
2. To input the radius of a sphere and print its volume and surface area.
Assignment 6
Questions based on Operators and Expressions in Java.
1. What will be the value of following expressions, if m is 5 initially?
(i) (3 * ++m) % 4 (ii) (3 * m++) % 4
2. What result will be produced by the expressions: A + B > 1750 ? 400 : 200, if:
(i) If A = 2000 and B = 1000 (ii) if A= 1000 and B = 1000
3. What will be the value of m = --p + p * ++n, where p = 10 and n = 7?
4. What will be the value of x = y++ + ++y +y, where y = 4?
5. What will be the value of (4 * ++a) % 5 and (4 * a++) % 5, where a = 4?
6. If x=4, y=7, d=10, w=20, then, state the results of following expression in true or
false:
(i) x>w (ii) x + 3 ==y (iii) x < d (iv) x + y == w
(v) y + d == x * w (vi) d – y != x + 3 (vii) d != y (viii) d + w == x * 4
7. If Y = 8, then what will be the output of the three statements :
System.out.println(++Y);
System.out.println(Y++);
System.out.println(++Y);
Assignment 7
Questions based on Mathematical methods.
1. What will the following function return when executed?
(i) Math.max(-17,-19)
(ii) Math.ceil(7.8)
5. What will be the final values stored in the variables when executed?
double a = -99.51;
double b = -56.25;
(i) double p = Math.abs(Math.floor(a));
(ii) double q = Math.sqrt(Math.abs(b));
Assignment 8
Programs based on Conditional constructs (if programs)
1. To find the largest of two numbers.
2. To input a number and check whether it is divisible by 7 or not.
Assignment 9
Programs based on Conditional constructs (if-else programs)
1. To input an integer and check whether it is an even or an odd number.
2. To input an integer and check whether it is a three digit number or not.
3. To input a character and check whether it is Uppercase or Lowercase.
4. To input a character and check whether it is a Vowel or a Consonant.
5. To input your age and check whether you are eligible to vote or not.
Assignment 10
Programs based on Conditional constructs (if-else-if programs)
1. To input the marks in English, and find the grade obtained, depending upon the
following criteria:
Marks in English Grade
90 and above A
70 to 89 B
50 to 69 C
35 to 49 D
Below 35 E
Up to Rs.10,000 10% 5%
Assignment 11
Programs based on Conditional constructs (if-else-if programs)
Write a program to input the cost price and the selling price of an article. If the selling
price is more than the cost price then calculate and display actual profit and profit per
cent otherwise, calculate and display actual loss and loss per cent. If the cost price and the
selling price are equal, the program displays the message 'Neither profit nor loss'.
Assignment 12
Programs based on Conditional constructs (nested if)
Write a program to input three angles of a triangle and check whether a triangle is
possible or not. If possible then check whether it is an acute-angled triangle, right-angled
or an obtuse-angled triangle otherwise, display 'Triangle not possible'.
Sample Input: Enter three angles: 40, 50, 90
Sample Output: Right=angled Triangle
Assignment 13
Programs based on Conditional constructs (nested if)
Given below is a hypothetical table showing rate of income tax for an India citizen, who
is below or up to 60 years.
Taxable income (TI) in ₹ Income Tax in ₹
Up to ₹ 2,50,000 Nil
Assignment 14
Programs on switch case
1. To input a number between 1 to 7 and print the corresponding day of the week.
2. To input a character and check whether it is a vowel or consonant.
Assignment 15
Programs based on Looping Statement (for)
1. To display the first ten terms of the following series
Assignment 16
Programs based on Looping Statement (while)
1. To enter a number and display the sum of its digits. (while)
2. To input a number. Check and display whether it is a Niven number or not. (A
number is said to be Niven which is divisible by the sum of its digits).
Example : 126 Sum of its digits = 1+2+6=9 and 126 is divisible by 9.
Assignment 17
Programs based on Looping Statement (do…while)
1. To display first ten numbers of the Fibonacci series.
2. To accept a number and check whether the number is palindrome or not. (A
number is said to be palindrome if the new number obtained after reversing the
digits is same as the original number.)
Assignment 18
Menu Driven program
'Kumar Electronics' has announced the following seasonal discounts on purchase of
certain items.
Discount Discount on
Purchase Amount
on Laptop Desktop PC
Assignment 20
Menu Driven program
Using switch statement, write a menu driven program for the following:
a) To find and display the sum of the series given below:
-----x-----