Question: In Java create an int variable called initial_value and get its value from the user with Scanner. Write a definite loop (for loop) that starts

In Java create an int variable called initial_value and get its value from the user with Scanner. Write a definite loop (for loop) that starts a counter at initial_value and add one to the counter each iteration. Iterate the loop 10 times and print the value of its counter to the power of 2. Do not use println, only print. For example, if the input is 5, then the output is: 5^2=25 6^2=36 7^2=49 8^2=64 9^2=81 10^2=100 11^2=121 12^2=144 13^2=169 14^2=196

This is what i have so far

import java.util.Scanner;

public class SquareLoop { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int initial_value; initial_value = scnr.nextInt(); int power = initial_value; for(int i = initial_value; i<=10 ;i++){ power *= initial_value; System.out.println(initial_value + "^2=" + power); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!