CPT120 Tutorial 2 Solved

25.00 $ 12.50 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


Rate this product


5.2: Continue to modify the TypeDemo class (from step 5) above as per the following instructions (there is no need to show/submit the version from 5.1 separately): After displaying the String (from exercise 1), increment the existing values of the number variables by 1. You can do this by saying either:

age+=1; or age++;

For the non-numerical variables (e.g. boolean, etc.), assign completely new new values.

Hint: When re-assigning values, we do not mention the data type (int, in this case) as we have already declared the variable with a data type before.

Finally, create a similar message to the one that you created at the end of exercise 1, create a second message that shows the new values, after the new values were re-assigned. E.g.

Again, yours must show all 8 fields/variable names and their new values (and you can use System.out… instead). If you do this right, the integer values will now show negative values (Optional: How does a positive number suddenly become a negative one? Listen to

Gayan’s explanation during the live lecture lesson)

In summary, after completion of exercise 2, your program should produce two outputs, showing “before” and “after” summaries of the variables and their contents.

Optional Exercise: You have seen the += and ++ operators (as in age+=1 or age++). Have you seen the rest of the Java operators? Which of these are important in everyday programming? What is operator precedence? There is no need to write answers to these but please follow Gayan’s explanation during the compulsory lecture lesson for this tutorial (weekly live lesson) to find out what they are, which ones are important, relevant to this unit, etc.

  1. Your Assignment 1 also requires you to store values like character names, relevant numbers, etc. in variables. For this week’s dummy submission of Assignment 1, at least copy the code from TypeDemo (exercises 1 and 2 above) in to your Assignment 1’s java file, get it to work and submit your Assignment 1’s java file via Canvas→Assignments→Assignment 1 (you can improve and re-submit any number of times before the deadline). Tip: At this stage it is fine if you do not have user inputs; programs are easier to write when they are developed iteratively. You can safely ignore this step if you have made your final submission; dummy submissions are for those who are yet to get started.
  • Independent_Investigation_Effort_02-g1u3qp.zip