diff --git a/src/ca/bcit/comp1510/assignment2/q3/Primes.java b/src/ca/bcit/comp1510/assignment2/q3/Primes.java index 74d16d8..daad114 100644 --- a/src/ca/bcit/comp1510/assignment2/q3/Primes.java +++ b/src/ca/bcit/comp1510/assignment2/q3/Primes.java @@ -1,22 +1,119 @@ package ca.bcit.comp1510.assignment2.q3; +import java.util.List; +import java.util.ArrayList; + +import java.util.Scanner; + /** *
This is where you put your description about what this class does. You * don't have to write an essay but you should describe exactly what it does. * Describing it will help you to understand the programming problem better.
* - * @author Your Name goes here - * @version 1.0 + * @author Braeden Sowinski + * @version 1.0.0 */ public class Primes { + + /** primes list up to nth number. */ + private ListThis is the main method (entry point) that gets called by the JVM.
* * @param args command line arguments. */ public static void main(String[] args) { - // your code will go here!!! - System.out.println("Question three was called and ran sucessfully."); - } + + Scanner scan = new Scanner(System.in); + + int bound = 0; + boolean valid = false; + + do { + System.out.print("Enter an upper bound: "); + if (!scan.hasNextInt()) { + System.out.println(scan.next() + " is not a valid integer.\n"); + continue; + } + + bound = scan.nextInt(); + + if (bound <= 1) { + System.out.println("Bound must be greater than 1.\n"); + continue; + } + + valid = true; + } while (!valid); + + scan.close(); + + Primes p = new Primes(bound); + + p.printPrimes(); + } }