Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribed

Please do give an explanation for the answer.image text in transcribed

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 / 7 8 9 10 11

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago