For this lab you will use unit testing to check a null setting using assertions. Use the commented template code provided to do the following:

Write a program that collects two integer inputs and assigns them to the variables starting_num

and multiplier. Multiply starting_num by multiplier and output the result. Repeat this process two more times, each time multiplying the previous result by multiplier. The three product outputs should be separated by a whitespace character, ending with a newline.

If the input is:

2 5

the output when

starting_num = 2

is:

10 50 250

Solution


import java.util.Scanner;

public class LabProgram {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in); 
      /* Type your code here. */
        int startingNum = scnr.nextInt();
        int multiplier = scnr.nextInt();
        int result = startingNum;
        String output = "";

        for (int i = 0; i < 3; i++) {
            result *= multiplier;
            if (i <=1){
               output += result + " ";
            }
            else {
               output += result;
            }
        }
       System.out.println(output);
   }
}