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

Author Question: Analyze the following code: // Enter an integer Scanner input = new Scanner(System.in); int number = ... (Read 45 times)

charchew

  • Hero Member
  • *****
  • Posts: 579

Question 1

What is the output of the following code? (Please indent the statement correctly first.)

int x = 9;
int y = 8;
int z = 7;

if (x > 9)
if (y > 8)
System.out.println("x > 9 and y > 8");
else if (z >= 7)
System.out.println("x <= 9 and z >= 7");
else
System.out.println("x <= 9 and z < 7");

◦ x <= 9 and z >= 7;
◦ x > 9 and y > 8;
◦ x <= 9 and z < 7;
◦ none

Question 2

Analyze the following code:

// Enter an integer
Scanner input = new Scanner(System.in);
int number = input.nextInt();

if (number <= 0)
System.out.println(number);
System.out.println(number);

◦ number is printed out once if number is positive
◦ number is printed out twice if number is negative
◦ number is always printed out at least once
◦ number is printed out twice if number is zero


Related Topics

Need homework help now?

Ask unlimited questions for free

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

kaykay69

  • Sr. Member
  • ****
  • Posts: 322
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




charchew

  • Member
  • Posts: 579
Reply 2 on: May 6, 2020
:D TYSM


T4T

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

 

Did you know?

About 3.2 billion people, nearly half the world population, are at risk for malaria. In 2015, there are about 214 million malaria cases and an estimated 438,000 malaria deaths.

Did you know?

All patients with hyperparathyroidism will develop osteoporosis. The parathyroid glands maintain blood calcium within the normal range. All patients with this disease will continue to lose calcium from their bones every day, and there is no way to prevent the development of osteoporosis as a result.

Did you know?

For pediatric patients, intravenous fluids are the most commonly cited products involved in medication errors that are reported to the USP.

Did you know?

Asthma occurs in one in 11 children and in one in 12 adults. African Americans and Latinos have a higher risk for developing asthma than other groups.

Did you know?

Most fungi that pathogenically affect humans live in soil. If a person is not healthy, has an open wound, or is immunocompromised, a fungal infection can be very aggressive.

For a complete list of videos, visit our video library