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


cdmart10

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

 

Did you know?

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

Did you know?

Acetaminophen (Tylenol) in overdose can seriously damage the liver. It should never be taken by people who use alcohol heavily; it can result in severe liver damage and even a condition requiring a liver transplant.

Did you know?

Only one in 10 cancer deaths is caused by the primary tumor. The vast majority of cancer mortality is caused by cells breaking away from the main tumor and metastasizing to other parts of the body, such as the brain, bones, or liver.

Did you know?

In 2006, a generic antinausea drug named ondansetron was approved. It is used to stop nausea and vomiting associated with surgery, chemotherapy, and radiation therapy.

Did you know?

Between 1999 and 2012, American adults with high total cholesterol decreased from 18.3% to 12.9%

For a complete list of videos, visit our video library