Question

1.20 LAB: Warm up: Basic output with variables This zyLab activity prepares a student for a...

1.20 LAB: Warm up: Basic output with variables

This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice.

A variable like userNum can store a value like an integer. Extend the given program as indicated.

  1. Output the user's input. (2 pts)
  2. Output the input squared and cubed. Hint: Compute squared as userNum * userNum. (2 pts)
  3. Get a second user input into userNum2, and output the sum and product. (1 pt)


Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs.

Enter integer:
4
You entered: 4
4 squared is 16 
And 4 cubed is 64!!
Enter another integer:
5
4 + 5 is 9
4 * 5 is 20

#include <iostream>
using namespace std;

int main() {
   int userNum;

   cout << "Enter integer:" << endl;
   cin >> userNum;

   /* Type your code here */

   return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

#include <iostream>

using namespace std;

int main() {

int userNum, anotherNum;

cout << "Enter integer:" << endl;

cin >> userNum;

cout<<"You entered: "<<userNum<<endl;

cout<<userNum<<" squared is "<<(userNum*userNum)<<endl;

cout<<"And "<<userNum<<" cubed is "<<(userNum*userNum*userNum)<<"!!"<<endl;

cout<<"Enter another integer:"<<endl;

cin>>anotherNum;

cout<<userNum<<" + "<<anotherNum<<" is "<<(userNum+anotherNum)<<endl;

cout<<userNum<<" * "<<anotherNum<<" is "<<(userNum*anotherNum)<<endl;

return 0;

}

Add a comment
Know the answer?
Add Answer to:
1.20 LAB: Warm up: Basic output with variables This zyLab activity prepares a student for a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Warm up: Basic output with variables

    1.14 LAB: Warm up: Basic output with variablesThis zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice.A variable like userNum can store a value like an integer. Extend the given program as indicated.Output the user's input. (2 pts)Output the input squared and cubed. Hint: Compute squared as userNum * userNum. (2 pts)Get a second user...

  • Help

    (1) Output the user's input. (2 pts) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter integer: 4 You entered: 4 (2) Extend to output the input squared and cubed. Hint: Compute squared as userNum * userNum. (2 pts) Enter integer: 4 You entered: 4 4 squared is 16  And 4 cubed is 64!!  (3) Extend to get a second user input into userNum2. Output sum and product. (1 pt) Enter integer: 4 You entered: 4 4 squared is 16  And 4 cubed is 64!! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20

  • Need the answer in Java 1.17 LAB*: Program: ASCII art This zyLab activity is the traditional...

    Need the answer in Java 1.17 LAB*: Program: ASCII art This zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous sections provide warm up exercises intended to help a student prepare for this programming assignment. (1) Output this tree. (2 pts) * *** ***** ******* *** (2) Below the tree (with two blank lines), output this cat. (3 pts) /\ /\ o o = = --- Hint: A backslash \ in a...

  • Program: ASCII art

    1.16 LAB*: Program: ASCII artThis zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous sections provide warm up exercises intended to help a student prepare for this programming assignment.(1) Output this tree. (2 pts)   *   ***  ***** *******   ***(2) Below the tree (with two blank lines), output this cat. (3 pts)/\   /\   o o  =   =   ---Hint: A backslash \ in a string acts as an escape character, such as with a newline \n. So, to print an actual backslash,...

  • 5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment,...

    5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous section provides warm up exercises intended to help a student prepare for this programming assignment. This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to...

  • Please help program in python read all instructions 2.13 LAB*: Program: Cooking measurement converter Output each...

    Please help program in python read all instructions 2.13 LAB*: Program: Cooking measurement converter Output each floating point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f}'.format(your_value) (1) Prompt the user for the number of cups of lemon juice, water, and agave nectar needed to make lemonade. Prompt the user to specify the number of servings the recipe yields. Output the ingredients and serving size. (Submit for 2 points) Note: This zyLab outputs a...

  • 11.11 LAB: Warm up: Online shopping cart (1) Build the ItemToPurchase class with the following specifications:...

    11.11 LAB: Warm up: Online shopping cart (1) Build the ItemToPurchase class with the following specifications: Attributes (6 pts) item_name (string) item_price (float) item_quantity (int) Default constructor (2 pt) Initializes item's name = "none", item's price = 0, item's quantity = 0 Method print_item_cost() Ex. of print_item_cost() output: Bottled Water 10 @ $1 = $10 (2) In the main section of your code, prompt the user for two items and create two objects of the ItemToPurchase class. (4 pts) Ex:...

  • Hello there, im trying to answer this question in c 4.22 LAB: Warm up: Drawing a...

    Hello there, im trying to answer this question in c 4.22 LAB: Warm up: Drawing a right triangle This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height...

  • Warm up: Parsing strings

    5.9 LAB: Warm up: Parsing strings(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt)Examples of strings that can be accepted:Jill, AllenJill , AllenJill,AllenEx:Enter input string: Jill, Allen(2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)Ex:Enter input string: Jill Allen Error: No comma in string. Enter input string: Jill, Allen(3) Extract the two words from the input string...

  • Please use C Programming language (Not C++) 7.6 LAB*: Warm up: Online shopping cart (Part 1)...

    Please use C Programming language (Not C++) 7.6 LAB*: Warm up: Online shopping cart (Part 1) (1) Create three files to submit: • Item ToPurchase.h - Struct definition and related function declarations • Item ToPurchase.c-Related function definitions • main.c-main function Build the ItemToPurchase struct with the following specifications: • Data members (3 pts) • char itemName • int itemPrice • int itemQuantity • Related functions • MakeltemBlank0 (2 pts) Has a pointer to an item To Purchase parameter. Sets item's...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT