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

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon task_1_1_3-2ycz9d.zip (2.2 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
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 employee’s 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.

 

  • task_1_1_3-2ycz9d.zip