Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe what is a SIEM system and its configuration approaches.

Answered: 1 week ago

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago