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 62 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
Thanks for the timely response, appreciate it


debra928

  • Member
  • Posts: 342
Reply 3 on: Yesterday
:D TYSM

 

Did you know?

Studies show that systolic blood pressure can be significantly lowered by taking statins. In fact, the higher the patient's baseline blood pressure, the greater the effect of statins on his or her blood pressure.

Did you know?

Cucumber slices relieve headaches by tightening blood vessels, reducing blood flow to the area, and relieving pressure.

Did you know?

Though the United States has largely rejected the metric system, it is used for currency, as in 100 pennies = 1 dollar. Previously, the British currency system was used, with measurements such as 12 pence to the shilling, and 20 shillings to the pound.

Did you know?

Lower drug doses for elderly patients should be used first, with titrations of the dose as tolerated to prevent unwanted drug-related pharmacodynamic effects.

Did you know?

Increased intake of vitamin D has been shown to reduce fractures up to 25% in older people.

For a complete list of videos, visit our video library