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 29 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
Great answer, keep it coming :)


vickybb89

  • Member
  • Posts: 347
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

Cutaneous mucormycosis is a rare fungal infection that has been fatal in at least 29% of cases, and in as many as 83% of cases, depending on the patient's health prior to infection. It has occurred often after natural disasters such as tornados, and early treatment is essential.

Did you know?

Limit intake of red meat and dairy products made with whole milk. Choose skim milk, low-fat or fat-free dairy products. Limit fried food. Use healthy oils when cooking.

Did you know?

Automated pill dispensing systems have alarms to alert patients when the correct dosing time has arrived. Most systems work with many varieties of medications, so patients who are taking a variety of drugs can still be in control of their dose regimen.

Did you know?

Adults are resistant to the bacterium that causes Botulism. These bacteria thrive in honey – therefore, honey should never be given to infants since their immune systems are not yet resistant.

Did you know?

More than nineteen million Americans carry the factor V gene that causes blood clots, pulmonary embolism, and heart disease.

For a complete list of videos, visit our video library