Programming_techniques_Assignment No. 02
Programming_techniques_Assignment No. 02
DEPARTMENT OF MATHEMATICS
B.Sc. honours in financial mathematics and industrial statistics
MSF1123: PROGRAMMING TECHNIQUES
1. Write and execute following Java programs then check the outputs.
4. i) Create a Java program that declares two integer variables a and b and initializes them
with values.
ii) Use compound operators to perform the following operations and update the values
of a and b:
(a) Add 5 to a.
(b) Subtract 3 from b.
(c) Multiply a by 2.
(d) Divide b by 4.
(e) Calculate the remainder of a when divided by 7.
iii) Print the values of a and b before and after each operation. Use separate print state-
ments to make the output clear.
iv) Ensure that the program demonstrates the use of compound operators for each oper-
ation mentioned above.
F = (C × 1.8) + 32
6. Write a Java program to find the area of the circle when the value for radius is given:
Area = π × r2
7. The diameter of the Sun is approximately 865,000 miles. The diameter of the Earth is
approximately 7,600 miles. Write a Jave program to calculate the followings:
****************************************