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 46 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
Gracias!


mjenn52

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

 

Did you know?

In 1864, the first barbiturate (barbituric acid) was synthesized.

Did you know?

Though “Krazy Glue” or “Super Glue” has the ability to seal small wounds, it is not recommended for this purpose since it contains many substances that should not enter the body through the skin, and may be harmful.

Did you know?

Human neurons are so small that they require a microscope in order to be seen. However, some neurons can be up to 3 feet long, such as those that extend from the spinal cord to the toes.

Did you know?

The U.S. Preventive Services Task Force recommends that all women age 65 years of age or older should be screened with bone densitometry.

Did you know?

There used to be a metric calendar, as well as metric clocks. The metric calendar, or "French Republican Calendar" divided the year into 12 months, but each month was divided into three 10-day weeks. Each day had 10 decimal hours. Each hour had 100 decimal minutes. Due to lack of popularity, the metric clocks and calendars were ended in 1795, three years after they had been first marketed.

For a complete list of videos, visit our video library