Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This should print:
- Even numbers between 50 and 100:
- 50 52 54 .......
- Odd numbers between 50 and 100: //but it gets stuck here.
- 51 53 55 ....... //and doesn't print these.
- /*
- * Class: CS1301/19
- * Term: Fall 2017
- * Dr. Haddad
- * Name: Ian Turner
- * Lab 6
- */
- public class OddEven
- {
- public static void main(String[] args)
- {
- int number = 50;
- for (int start = 0; start < 101; start++, number ++)
- {
- if (start == 0)
- {
- System.out.println("Even numbers between 50 and 100: ");
- }
- if (start < 51)
- {
- if (number % 2 == 0)
- System.out.print(" " + number);
- continue;
- }
- number = 50;
- if (start == 51)
- {
- System.out.println("\nOdd numbers between 50 and 100: ");
- }
- if (start < 101)
- {
- if (number % 2 != 0)
- {
- System.out.print(" " + number);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement