java2
Assignment 2
Due date: 1/3/2016 at 11:59 PM
`
Course Title: Business Computer Languages
Course Code : IT 401
Assignment 2
Note :
· Due date: 03/01/2016 at 11:59 PM.
· 05 Marks
· Copied assignment will be graded zero mark.
· Assignment submitted after due date will not be accepted; it will be considered to be late and will have zero mark.
Q1. Identify and correct the error(s) in each of the following: [1.5 Points]
a) if (1 <= x <= 10)
System.out.println(x);
b) if (x = 1)
y++;
else if (x = 2)
y = y + 2;
c) final double CM_PER_INCH = 2.54;
CM_PER_INCH = 2.55;
Q2. What are the values of the following expressions? In each line, assume that
1. What are the values of the following expressions? In each line assume that [1.5 Points] double X = 2.5, Y = -1.5; int M = 18, N = 4; String S = "Hello", T = "World";
0. X + N * Y - ( X + N ) * Y
0. M / N + M % N
0. 5 * X - N / 5
0. S + T
0. S + N
0. ( 1 - ( 1 - ( 1 - ( 1 - N ))))
Q3. Write a program called CheckPassFail which read the mark from user and prints "PASS" if the mark is more than or equal to 60; or prints "FAIL" otherwise. [2 Points]
2 | Page