This topic contains a solution. Click here to go to the answer

Author Question: Analyze the following code:Code 1:int number = 45;boolean even;if (number % 2 == 0) even = true;else ... (Read 176 times)

crazycityslicker

  • Hero Member
  • *****
  • Posts: 537

Question 1

The following code displays ________.

double temperature = 50;

if (temperature >= 100)
System.out.println("too hot");
else if (temperature <= 40)
System.out.println("too cold");
else
System.out.println("just right");

◦ just right
◦ too hot
◦ too hot too cold just right
◦ too cold

Question 2

Analyze the following code:

Code 1:

int number = 45;
boolean even;

if (number % 2 == 0)
even = true;
else
even = false;

Code 2:

boolean even = (number % 2 == 0);

◦ Both Code 1 and Code 2 are correct, but Code 2 is better.
◦ Code 1 has compile errors.
◦ Code 2 has compile errors.
◦ Both Code 1 and Code 2 have compile errors.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by crazycityslicker on May 6, 2020

zhanghao

  • Sr. Member
  • ****
  • Posts: 316
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 25% of students answer this correctly




crazycityslicker

  • Member
  • Posts: 537
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


Animal_Goddess

  • Member
  • Posts: 339
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

An identified risk factor for osteoporosis is the intake of excessive amounts of vitamin A. Dietary intake of approximately double the recommended daily amount of vitamin A, by women, has been shown to reduce bone mineral density and increase the chances for hip fractures compared with women who consumed the recommended daily amount (or less) of vitamin A.

Did you know?

The longest a person has survived after a heart transplant is 24 years.

Did you know?

Essential fatty acids have been shown to be effective against ulcers, asthma, dental cavities, and skin disorders such as acne.

Did you know?

People about to have surgery must tell their health care providers about all supplements they take.

Did you know?

Your skin wrinkles if you stay in the bathtub a long time because the outermost layer of skin (which consists of dead keratin) swells when it absorbs water. It is tightly attached to the skin below it, so it compensates for the increased area by wrinkling. This happens to the hands and feet because they have the thickest layer of dead keratin cells.

For a complete list of videos, visit our video library