/* * Name:David Brock * * Class/Block:6 * * Lab: lab10 * * Description: This assignment is meant to demonstrate the use of For Loops and If Statements. A flag set as a boolean will be used to determine the output. * * */import java.util.*;import java.io.*;import static java.lang.System.*;public class lab10{ public void run() { System.out.println("------------------------------"); System.out.println("====== EXECUTION BEGINS ======"); System.out.println("------------------------------"); System.out.println("------------------------------"); System.out.println("======Enter data segment======"); System.out.println("------------------------------"); Scanner k = new Scanner(System.in); System.out.print("Enter starting number:: "); int a = k.nextInt(); System.out.print("Enter ending number:: "); int z = k.nextInt(); System.out.println("-------------------------------"); System.out.println("======process data segment====="); System.out.println("-------------------------------"); int primes = 0; for (int i=a; i<= z; i++) { boolean prime = true; for (int l = 2; l<i; l++) { if((i%l) == 0) { prime = false; break; } } if (prime == true){ primes ++; } } System.out.println("-------------------------------"); System.out.println("======display data segment====="); System.out.println("-------------------------------"); System.out.println("Prime numbers between " + a + " and " + z + ":: " + primes); out.println("-------------------------------"); out.println("======Execution terminates====="); out.println("-------------------------------"); } public static void main (String args[]) { lab10 myLab = new lab10(); myLab.run(); }}