Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Bounds;
- import java.util.Scanner;
- public class Bounds_Problem {
- public static void main( String[] args ) {
- // Declare Variables
- int starting_number = 0, step = 0, upper_bound = 0, i = 0;
- // Read in from user starting number, step size and upper bounds.
- Scanner startInput = new Scanner( System.in );
- System.out.println( "Please enter a staring number. " );
- starting_number = startInput.nextInt();
- Scanner stepSize = new Scanner( System.in );
- System.out.println( "Please enter a step size. " );
- step = stepSize.nextInt();
- Scanner upperBound = new Scanner( System.in );
- System.out.println( "Please enter an upper bounds. " );
- upper_bound = upperBound.nextInt();
- // Loop terminates when the starting number is greater than or equal to upper bounds.
- while( starting_number < upper_bound ) {
- // Print out numbers after calculations.
- System.out.print( starting_number + " " );
- starting_number = starting_number + step;
- // Counter
- i++;
- // When counter is equal to 10 print newline
- if( i == 10 ) {
- System.out.print( "\n" );
- i = 0;
- }
- }
- stepSize.close();
- upperBound.close();
- startInput.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement