answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
posledela
1 year ago
15

A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated. (1) Ou

tput the user's input.Enter integer: 4 You entered: 4(2) Extend to output the input squared and cubed. Hint: Compute squared as userNum * userNum. (Submit for 2 points, so 4 points total).Enter integer: 4 You entered: 44 squared is 16 And 4 cubed is 64!!(3) Extend to get a second user input into userNum2. Output sum and product. (Submit for 1 point, so 5 points total).Enter integer: 4 You entered: 44 squared is 16 And 4 cubed is 64!! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20import java.util.Scanner;public class OutputWithVars {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);int userNum = 0;System.out.println("Enter integer: ");userNum = scnr.nextInt();return;}}
Computers and Technology
1 answer:
UNO [17]1 year ago
6 0

Answer:

Write the following lines of code just before the return statement

//1

       System.out.println("You entered "+userNum);        

       // 2

       System.out.println(userNum+" squared is "+(Math.pow(userNum, 2))+" and "+userNum+" cubed is "+(Math.pow(userNum, 3)));

       //3

       int userNum2 = 0;

       System.out.print("Enter another integer: ");

       userNum2 = scnr.nextInt();

int sum = userNum + userNum2;

       System.out.println(userNum+" + "+userNum2+" is "+sum);

int product = userNum * userNum2;

       System.out.println(userNum+" * "+userNum2+" is "+product);

Explanation:

I continued the program from where you stopped in the question

The explanation has been added as an attachment

Download docx
You might be interested in
A ____ partition contains the data necessary to restore a hard drive back to its state at the time the computer was purchased an
Oxana [17]
The answer is back up
8 0
1 year ago
Read 2 more answers
Select the correct answer. Andy wants to become a multimedia producer. Which degree can help him achieve this goal? A. bachelor’
tatuchka [14]

Answer:

C. bachelor’s degree in filmmaking

Explanation:

Because Andy wants to become a multimedia producer, the degree that would best help him achieve his goal is a bachelor's degree in filmmaking.

Multimedia has to do with both audio, video and graphics or animations because it encompasses multiple media files.

Filmmaking has to do with the various forms of making and producing films. Filmmaking has to do with multiple media (multimedia) and it would help him achieve his goal.

7 0
1 year ago
What protocol communicates data between routers representing the edges of autonomous systems?Distance-vectorLink stateInterior g
Nata [24]

Explanation:

Exterior gateway protocol are the routing protocols that are used on the internet for exchanging routing information among the autonomous system. These autonomous systems can be gateway protocol, vector routing protocol.

8 0
1 year ago
3. Megan and her brother Marco have a side business where they shop at flea markets, garage sales, and estate
Neko [114]

Answer:

a

Explanation:

Megan doesn't have a registered business. She can't claim insurance

4 0
1 year ago
Menus are attached to windows by calling the _____ method.
Kruka [31]

Answer: setJMenubar

Explanation:Menus that are component of the Menu bar that display the options and tools for any function that can be performed in the system have the connection with the window in the field of java through the command of the setJMenubar. It is the command which is given to execute to bring the menu to the particular frame and get it attached according to the JFrame. Therefore, the correct option is setJMenubar.

6 0
2 years ago
Other questions:
  • What are the pros and cons of using unique closing reserved words on compound statements?
    15·1 answer
  • An mp3 takes up about 16 kilobytes of memory per second of music. if you owned a one terabyte hard drive and filled it with only
    15·1 answer
  • In the game Beehive, you play the role of a worker bee who must watch over her hive. Your duties include (among others) directin
    12·2 answers
  • #Remember that Fibonacci's sequence is a sequence of numbers
    14·1 answer
  • A triangular number is a number that is the sum of the integers from 1 to some integer n. Thus 1 is a triangular number because
    11·1 answer
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • Earlier in the day, you created a user account for Brenda Cassini (bcassini). When she tries to log in, she can't. You realize t
    9·2 answers
  • Exercise 3: Function Write a function named word_count that accepts a string as its parameter and returns the number of words in
    10·1 answer
  • ___________is used for drawing 3D objects in the field of Science and Engineering.
    12·2 answers
  • The word “computer” has become associated with anything related to screens and keyboard. However, these are not the only parts t
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!