Question: Please do give an explanation for the answer. L1 (0.4 marks) Code in the method l1() in the MainClass class of this week's downloaded project.


Please do give an explanation for the answer.
L1 (0.4 marks) Code in the method l1() in the MainClass class of this week's downloaded project. Code to display the numbers 3, 8,5, and 2 each on its own output line. Add them up in code and display their sum on yet another line. Do this 3 ways: Without using variables at all Using 4 independent variables (one for each number) and another variable for their sum Reusing just one variable for the numbers and one additional variable for their sum . . Data Types L2 (0.8 marks) C Code in the method 12() in the MainClass class of this week's downloaded project. Code declaration statements (including the assignment of an initial value) for the following values: Your height in centimeters The state of a traffic light, which can either RED, YELLOW, or GREEN the number of students enrolled in FIT1051 so far the age of a primary school student in years the balance of a bank account the maximum speed of an electric car The capacity of electric car batteries in kw/h Write code to display the value of each of the above together with a suitable description (e.g. Your height: 185 cm). Code in the method 13() in the MainClass class of this week's downloaded project. Declare variables with data type float, int, char, String, double and boolean and give all of them an initial value of the appropriate type. Now try to assign the value of each to the other variables. You will have to comment out assignment statements that cause an error. Which conversions does Java perform automatically? Which conversions will Java perform with a cast? What are the side effects of these cast(s)? 1 2 CW 4 5 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
