1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Salsk061 [2.6K]
3 years ago
6

Your program will search for prime numbers. You will first ask the user for the range of values to search, and use for loops to

progress through all the numbers chosen. Note to determine if a number is a prime number, you must check to find out if there are any values besides 1 and itself that divide into it evenly. If any other numbers found then it is not prime. To check if any number is divisible, use the modulus operator which gives the value of the remainder of a division. List off all prime numbers found within a range given by the user. Do not list off numbers that are not prime. Also output at bottom the total number of primes from. See sample output at bottom of project sheet. Hint: first write the code that will determine if a given single number is prime or not, then put it in a larger loop. write in java.
Computers and Technology
1 answer:
Stells [14]3 years ago
7 0

Answer:

Java code is given below

Explanation:

import java.util.Scanner;

public class Prime {

public static void main(String args[]) {

int first, last, flag = 0, i, j;

Scanner s = new Scanner(System.in);

System.out.println("Enter the lower limit :");

first = s.nextInt();

System.out.println("Enter the upper limit :");

last = s.nextInt();

System.out.println("The prime numbers in between the entered limits are :");

int x = 0;

for (i = first; i <= last; i++) {

for (j = 2; j < i; j++) {

if (i % j == 0) {

flag = 0;

break;

} else {

flag = 1;

}

}

if (flag == 1) {

x++;

System.out.println(i + " ");

}

}

System.out.println("Total number of prime numbes between " + first + " and " + last + " are " + x);

}

}

You might be interested in
Write the printItem() method for the base class. Sample output for below program:
Anna [14]

Answer:

The printItem() method code is filled in the explanation, highlighted with bold font.

Explanation:

// ===== Code from file BaseItem.java =====

public class BaseItem {

  protected String lastName;

  public void setLastName(String providedName) {

      lastName = providedName;

      return;

  }

// FIXME: Define printItem() method

/* Your solution goes here */

  public void printItem() {

      // TODO Auto-generated method stub

      System.out.println("Last name: "+lastName);

  }

}

// ===== end =====

4 0
3 years ago
software that instructs the computer how to run applications and controls the display/keyboard is known as the what?
Tomtit [17]
<span>The software that instructs the computer how to run applications and controls the display /keyboard is known as DRIVERS software, A driver is a software program that enables a specific hardware device to work with a computers operating system. Drivers may be required for internal components such as video cards and optical media drives.</span>
7 0
3 years ago
An example of a current disruptive technology is a?
guapka [62]
Smart Watches are taking over normal watches. They are getting WAYYY cheaper. There is one for about $14
6 0
3 years ago
Read 2 more answers
What are the high and low temperatures on Saturn? (C)
slava [35]
Saturn contains three layers of clouds. The upper layers of ammonia ice have temperatures ranging from minus 280 F to minus 170 F. The next layer contains water ice, with temperatures from minus 127 F to 26.Temperatures in the lower layers climb as high as 134 F.
8 0
3 years ago
Please help on both of these questions will give brainliest<br> !!
Alja [10]

I think the first one is All of the above

3 0
3 years ago
Read 2 more answers
Other questions:
  • Assume you're using a three button mouse. to access shortcut menus you would
    10·1 answer
  • The united states attempted to halt the communist revolution in cuba by​
    7·1 answer
  • What does it mean for a school to be “accredited”?
    5·1 answer
  • For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, D
    5·1 answer
  • What is the TAG to begin a Web page, as recommended by the W3C?
    13·1 answer
  • Instructions:Select the correct answer.
    9·2 answers
  • PLZ HELP FAST!!!! 
    7·2 answers
  • Though most of the content on this social network is uploaded by amateurs, many companies offer streaming video content related
    10·1 answer
  • what is a simulation? a) simulation is the process of creating dashboards in excel. b) simulation is the process of complex form
    9·1 answer
  • Differentiate between symmetric and asymmetric encryption
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!