[Solved] CPT121 Task 1.1.3 Practice Exercises Variables, types and casting

$25

File Name: CPT121_Task_1.1.3_Practice_Exercises__Variables,_types_and_casting.zip
File Size: 621.72 KB

SKU: [Solved] CPT121 Task 1.1.3 Practice Exercises – Variables, types and casting Category: Tag:
5/5 - (1 vote)

Task 1.1.3 Practice Exercises Variables, types and casting

  1. Give appropriate declarations (type and name) for variables used to store the following values:
  2. a.An employees taxable salary e) The average rainfall for the past month
    1. The month number within a year f) A letter to hold an answer (y or n)
    2. An employee identification number g) The constant string Hello
    3. The capacity of a tank in cubic inches h) The conversion rate from $AUS to $US
  3. Assuming that the types of the variables x, y, and z are int, float and double respectively, which of the following statement(s) are likely to result in error ?
  4. a) x = y; b) x = z; c) y = x;
  5. d) y = z; e) z = x; f) z = y;
  6. The following code segment prints an incorrect result (instead of the expected result of sqr = 10000000000 ).

int num1 = 100000; int sqr = num1 * num1;

System.out.println(sqr = + sqr);

Describe the problem / error that has occurred and suggest a solution or work-around to the problem which will allow the correct result to be stored and printed.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CPT121 Task 1.1.3 Practice Exercises Variables, types and casting
$25