Flow Control 5

Description

The purpose of this challenge is to use the IF statement to control program flow and to use basic arithmetic expressions. This challenge simulates a rudimentary stock chart.

Requirements

  1. Take a glance at the Sample Interaction below to get an idea of how the code runs
  2. Declare a double variable called previous_price
  3. Declare a double variable called current_price
  4. Declare a string variable called symbol
  5. Declare a string variable called company
  6. Ask the user to enter a value for symbol
  7. Ask the user to enter a value for company
  8. Ask the user to enter a value for previous_price
  9. Ask the user to enter a value for current_price
  10. If the price of the stock has increased, show a message “It’s a bull market”
  11. If the price of the stock has decreased, show a message “It’s a bear market”
  12. if the price of the stock didn’t change, show a message “It’s a flat market”
  13. Also, as part of the message for steps 10 and 11, indicate the percentage change. (see below)

Formatting your output

  1. Include the <iomanip> header file. This will allow you to use various options to format your output. Add this line under your main include line. See below.
    #include <iostream>
    #include <iomanip>
  2. It’s good practice to initialize variables to default values that make sense (for example, set fee to 0.00)
  3. Include the code below before any other cout lines. The setprecision(x) will display your decimal output with x decimal places.
cout << fixed << setprecision(2);

Sample Interaction / Output

-- Welcome to CSUB Brokerage --
What is the stock symbol? GOOG
What is the company name? Google
What was the previous stock price? 850
What is the current price? 1000

It's a bull market! Google (GOOG) went up 17.65%

RUN IT AGAIN:

-- Welcome to CSUB Brokerage -- 
What is the stock symbol? GOOG 
What is the company name? Google 
What was the previous stock price? 850 
What is the current price? 425

It's a bear market! Google (GOOG) went down 50.00%.

RUN IT AGAIN:

-- Welcome to CSUB Brokerage -- 
What is the stock symbol? GOOG 
What is the company name? Google 
What was the previous stock price? 850 
What is the current price? 850

It's a flat market! Google (GOOG) stock price didn't change.

LEGEND
PROGRAM OUTPUT
USER ENTRY 
FROM INPUT 

CATALOG ID: CPP-FLOW0005

Print Requirements