Chapter 2 Lab
Use variables, and Arithmetic Operators

Created by: Perpetua Ruiz

Instructions:

  1. Write your programs in Python or C++ (programming languages)
    Include comments in each program
    3. Display your solutions such as graphs, pseudocode, in a word document. Upload this Word file
    4. Upload the file containing the program’s code
  2. Present the output of your program in a Word document. Upload this Word file

 

Problem 1 (2 pts): Given the expression 40 – 3**2 + 8/3**2*10
a) What is the output of the expression? Check your answer by writing and running a program in Python or C++

  1. b) Based on precedence and associativity of the arithmetic operators. Correctly parenthesize the expression such that you get the same output as in part (a) Check your answer by writing and running a program in Python or C++

Problem 2: (3 pts): Predict the output and check your answer by writing and running a program in Python or C++

  1. a) 2**2**3
  2. b) 2**(2**3)
  3. c) (2**2) **3

Problem 3:  
a) Create a flowchart or pseudocode that shows the logic for a program that prompts the user to input an integer that represents cents. The program will then calculate the smallest combination of coins that the user has. For example, 32 cents is 1 quarter, 1 nickel, and 2 pennies (3 pts)

  1. b) Write the program for the problem described in part (a). You may write the program’s code in Python Python or C++ (2 pts)

    Customer Area

    Make your order right away

    Confidentiality and privacy guaranteed

    satisfaction guaranteed