1answer.
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
BartSMP [9]
2 years ago
12

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

put the user's input.Enter integer: 4You 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: 4You 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: 4You entered: 44 squared is 16 And 4 cubed is 64!!Enter another integer: 54 + 5 is 94 * 5 is 20LABACTIVITY1.16.1: Basic output with variables (Java)0 / 5OutputWithVars.javaLoad default template...import 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;}}import 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;}}Develop modeSubmit modeRun your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.
Computers and Technology
1 answer:
dimulka [17.4K]2 years ago
8 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 int userNum;

 Scanner input = new Scanner(System.in);

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

 userNum = input.nextInt();

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

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

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

 int userNum2;

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

 userNum2 = input.nextInt();

 int sum= userNum + userNum2; int product = userNum2 * userNum;

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

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

Explanation:

This declares userNum

 int userNum;

 Scanner input = new Scanner(System.in);

This prompts the user for input

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

This gets user input from the user

 userNum = input.nextInt();

Number (1) is implemented here

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

Number (2) is implemented here

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

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

This declares another variable userNum2

 int userNum2;

This prompts the user for another input

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

This gets user input from the user

 userNum2 = input.nextInt();

This calculates the sum and the product

 int sum= userNum + userNum2; int product = userNum2 * userNum;

Number (3) is implemented here

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

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

You might be interested in
Find an example of a print or Internet ad that includes images and text, and then answer
WARRIOR [948]

4. Find an example of a print or Internet ad that includes images and text, and then answer the following questions about it.

           a. Describe the ad. (1-3 sentences. 1.0 points)

Mcdonald's all day breakfast. It shows their breakfast items, with high-quality images.

b. What do you think this ad's marketing message is? (1-5 sentences. 2.0 points) TIP: Does it use a specific desire or fear, or does it try to show how the product is a need or how it solves a problem?

They use desire because they show their delicious looking food, and the customers are wanting it.

c. Is the ad trying to get people to do something? If so, what is it trying to get people to do? If it isn't trying to get people to do something, what do you think the point of the ad is? (1-5 sentences. 2.0 points)

The ad is trying to get people to stop at Mcdonalds and buy their breakfast items

           d. Do you think this ad is effective? Why or why not? (1-5 sentences. 2.0 points)

Yes I think this ad is effective because it is showing high quality images of their breakfast items that encourage people to stop by and try their products.

3 0
3 years ago
What are the role, responsibilities, and required background of the production designer of a film?
IRISSAK [1]
There are many roles and responsibilities and required background for the production designer of a film. For a complte and detailed view of this career, visit the following website.
6 0
3 years ago
One way to add a table to a presentation is to click on Clip Art under the Insert tab. click on WordArt under the Insert tab. ri
SpyIntel [72]
Huh? What is this? …..
7 0
2 years ago
Increment the intLocal, intStatic and intClass variables using the intone constant
n200080 [17]

Answer:

In VB.net the keyword Static is not meant the same as in C#. In VB.net the static variable is termed as the shared variable and has the scope throughout the class. And this intStatic and intclass means the same. And for intClass we use the shared keyword, as shown in the image attached.

Explanation:

Here num2 is a local variable, and num2 is a shared variable. a is constant and used for incrementing. The rest is explained in the image.

3 0
2 years ago
What form of marine life filters the water of Chesapeake Bay?
wel
Answer: plankton
explanation: intuition
3 0
2 years ago
Other questions:
  • The BasicSet 2 class implements the Set ADT by wrapping an object of the Linked Collection class and:______.
    15·1 answer
  • Your laptop doesn't have a serial port. what type of connector will your laptop require
    6·1 answer
  • Which of the following statements is/are true by definition.
    5·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • Which of the following statements are true of software engineers? Check all of the boxes that apply. They are responsible for wr
    11·2 answers
  • For each obstacle, select the best solution. failing to find other members for a club: failing a class: failing to get the credi
    9·2 answers
  • Write a python program that should determine from the range you choose to enter :
    9·1 answer
  • Help asap !!!<br>which component of cpu controls the overall operation of computer..​
    9·1 answer
  • What is the second step when designing an algorithm?
    12·2 answers
  • Bill, a project manager, wants to hire external resources. What step should Bill take before hiring external resources?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!