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

Author Question: Suppose the input for number is 9. What is the output from running the following program?import ... (Read 28 times)

s.tung

  • Hero Member
  • *****
  • Posts: 577
Suppose the input for number is 9. What is the output from running the following program?

import java.util.Scanner;

public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter an integer: ");
int number = input.nextInt();
int i;
boolean isPrime = true;
for (i = 2; i < number && isPrime; i++) {
if (number % i == 0) {
isPrime = false;
}
}
System.out.println("i is " + i);
if (isPrime)
System.out.println(number + " is prime");
else
System.out.println(number + " is not prime");
}
}

◦ i is 3 followed by 9 is prime
◦ i is 4 followed by 9 is not prime
◦ i is 3 followed by 9 is not prime
◦ i is 4 followed by 9 is prime


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by s.tung on May 6, 2020

lkanara2

  • Sr. Member
  • ****
  • Posts: 329
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 50% of students answer this correctly




s.tung

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


daiying98

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

 

Did you know?

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

Did you know?

The immune system needs 9.5 hours of sleep in total darkness to recharge completely.

Did you know?

To maintain good kidney function, you should drink at least 3 quarts of water daily. Water dilutes urine and helps prevent concentrations of salts and minerals that can lead to kidney stone formation. Chronic dehydration is a major contributor to the development of kidney stones.

Did you know?

There are immediate benefits of chiropractic adjustments that are visible via magnetic resonance imaging (MRI). It shows that spinal manipulation therapy is effective in decreasing pain and increasing the gaps between the vertebrae, reducing pressure that leads to pain.

Did you know?

The top 10 most important tips that will help you grow old gracefully include (1) quit smoking, (2) keep your weight down, (3) take supplements, (4) skip a meal each day or fast 1 day per week, (5) get a pet, (6) get medical help for chronic pain, (7) walk regularly, (8) reduce arguments, (9) put live plants in your living space, and (10) do some weight training.

For a complete list of videos, visit our video library