Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*This code is intended to be pseudo-code, and will not work if compiled and run.
- *Instead, it should be used as a starting point for writing actual code.
- *Yahoo Answers Question: https://answers.yahoo.com/question/index?qid=20141019091026AAQF8qU
- **/
- //global variables
- int tempNum; //holds number as it's read
- int numPrime; //increment by 1 each time a prime is found
- //loop to read in numbers until end of file is reached
- while(file.hasNext()){
- //read in number (integer in this example) and store in variable temporarily
- tempNum = file.nextInt();
- //conditional statement (if statement) to check for prime numbers
- if(tempNum % 2 == 0){
- //number is prime, since the number divided by 2 does not produce a remainder
- //so we will increment the "numPrime" variable by 1
- numPrime++;
- }
- }
Add Comment
Please, Sign In to add comment