Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package class170629;
- import java.util.Scanner;
- public class WhileSlide29Ex01 {
- public static void main(String[] args) {
- /*
- * כתוב תוכנית הקולטת מהמשתמש מספרים שלמים עד אשר הוקלדו בדיוק 5 מספרים
- * זוגיים
- */
- final int NO_OF_NUMBERS = 5;
- // create a scanner
- Scanner s = new Scanner(System.in);
- int n; // input: integer value
- int even = 0; // calculated: counter for even numbers
- do {
- // ask for input
- System.out.print("Enter an integer number: ");
- // get and save input number
- n = s.nextInt();
- if (n % 2 == 0)
- even += 1;
- } while (even < NO_OF_NUMBERS); // loop if the number of event numbers
- // less than 5
- System.out.println("End of data!");
- s.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement