Advertisement
MrDoyle

For) Counting Machine Revisited

Nov 13th, 2020
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         System.out.println();
  7.         System.out.print("Count from: ");
  8.         Scanner keyboard1 = new Scanner(System.in);
  9.         int num1 = keyboard1.nextInt();
  10.  
  11.         System.out.print("Count to: ");
  12.         Scanner keyboard2 = new Scanner(System.in);
  13.         int num2 = keyboard2.nextInt();
  14.  
  15.         System.out.print("Count by: ");
  16.         Scanner keyboard3 = new Scanner(System.in);
  17.         int num3 = keyboard3.nextInt();
  18.        
  19.         int n;
  20.         System.out.println();
  21.  
  22.         for (n=num1 ; n <= num2 ; n = n+num3){
  23.             System.out.print(n + " ");
  24.         }
  25.         System.out.println();
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement