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 122 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


mjenn52

  • Member
  • Posts: 351
Reply 3 on: Yesterday
Gracias!

 

Did you know?

The Food and Drug Administration has approved Risperdal, an adult antipsychotic drug, for the symptomatic treatment of irritability in children and adolescents with autism. The approval is the first for the use of a drug to treat behaviors associated with autism in children. These behaviors are included under the general heading of irritability and include aggression, deliberate self-injury, and temper tantrums.

Did you know?

Parkinson's disease is both chronic and progressive. This means that it persists over a long period of time and that its symptoms grow worse over time.

Did you know?

No drugs are available to relieve parathyroid disease. Parathyroid disease is caused by a parathyroid tumor, and it needs to be removed by surgery.

Did you know?

As many as 28% of hospitalized patients requiring mechanical ventilators to help them breathe (for more than 48 hours) will develop ventilator-associated pneumonia. Current therapy involves intravenous antibiotics, but new antibiotics that can be inhaled (and more directly treat the infection) are being developed.

Did you know?

Eat fiber! A diet high in fiber can help lower cholesterol levels by as much as 10%.

For a complete list of videos, visit our video library