Program is to list all prime numbers between two entered numbers.

import java.util.Scanner; public class question6 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter lower int:"); int x = input.nextInt(); System.out.println("Enter larger int:"); int y = input.nextInt(); boolean prime = false ; int i = x; for ( i = x; i <= y; i++) { // tested works returns 2 if (i == 2) { prime = false; System.out.println( i + " Prime"); } for (i = x; i <= y; i++){ // tested works returns anything divisible by two and not two itself. if (i % 2 == 0) { prime = true; } for (int j = x; j<=y; j++) { if ((i % j) == 0) { prime = true; } } /*while (i <= y) { int j = i; if (((Math.sqrt(i)) %j) == 0){ System.out.println(i + " Not Prime"); } pFlag = true; j++; } */ if (!prime) System.out.println(i);