Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is have to be done in java Create a package named bounds and create a progr

ID: 3871310 • Letter: T

Question

This is have to be done in java

Create a package named bounds and create a program that reads from the Keyboard and prompts the user for 3 numbers starting number, upper bound, step size. Print out the user's input values. Then write out the sequence of numbers: starting_number (starting_number step size) (starting_number+2 step size) Continue printing numbers as long as number upper_bound. Write out no more than 10 numbers per line. For example: starting number-2, upper bound-90 and step size-4 should generate the numbers: 2 6 10 14 18 22 26 30 34 38 42 46 50 54 58 62 66 70 74 78 82 86

Explanation / Answer

import java.util.Scanner;

public class Bounds {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner scanner = null;

try {

int startingNumber, upperBound, stepSize;

scanner = new Scanner(System.in);

System.out.print("Enter the starting Number:");

startingNumber = scanner.nextInt();

System.out.print("Enter the upper bound:");

upperBound = scanner.nextInt();

System.out.print("Enter the step size:");

stepSize = scanner.nextInt();

System.out.println("startingNumber: " + startingNumber

+ " upperBound: " + upperBound + " stepSize: " + stepSize);

int sequnce = 0;

for (int i = 0, j = 1; (startingNumber + i * stepSize) < upperBound; i++, j++) {

sequnce = startingNumber + i * stepSize;

if (j < 10 || (j % 10) != 0)

System.out.print(sequnce + " ");

else

System.out.println(sequnce);

}

} catch (Exception e) {

// TODO: handle exception

}

}

}

OUTPUT:

Enter the starting Number:2
Enter the upper bound:90
Enter the step size:4
startingNumber: 2 upperBound: 90 stepSize: 4
2 6 10 14 18 22 26 30 34 38
42 46 50 54 58 62 66 70 74 78
82 86

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote