Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a program that reads two positive integer numbers and prints how many numbers p
- * exist between them such that the reminder of the division by 5 is 0. */
- import java.util.Scanner;
- public class NumbersInIntervalDividableBy5 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- System.out.print("Enter a positive Integer Number for Start: ");
- int start = scan.nextInt();
- System.out.print("Enter other positive Integer number, bigger from the First: ");
- int end = scan.nextInt();
- scan.close();
- if (start > 0 && end > start) {
- int counter = 0;
- for (int i = start; i <= end; i++) {
- if (i % 5 == 0) {
- counter++;
- }
- }
- System.out.printf("In that Interval has %d numbers dividable by 5, without remainder!\n",
- counter);
- } else {
- System.out.println("Error! - Wrong Input!!!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement