CSC1300: LAB 2

$30.00 $24.00

Complete this lab with your lab partner. You have a single group submission folder to upload your zipped lab. Concepts: Elements and syntax of a C++ program Calculations using math expressions Strings Simple output STEP ONE: stock commission program Image copied from http://www.quickmeme.com/meme/35i3ef Description / Specifications This program was taken from page 82, Exercise 2-17…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

Complete this lab with your lab partner.

You have a single group submission folder to upload your zipped lab.

Concepts:

  • Elements and syntax of a C++ program
  • Calculations using math expressions
  • Strings
  • Simple output

STEP ONE: stock commission program

Image copied from http://www.quickmeme.com/meme/35i3ef

Description / Specifications

This program was taken from page 82, Exercise 2-17 in the book Starting out with C++ From Control Structures through Objects by Tony Gaddis. Kathryn bought 750 shares of stock at a price of $35.00 per share. She must pay her stockbroker a 2 percent commission for the transaction. Write a program that calculates and displays the following:

  • The amount paid for the stock alone (without the commission)
  • The amount of the commission
  • The total amount paid (for the stock plus the commission)

Dollar amounts should always display exactly 2 decimal places. In order to do this, you will need to #include<iomanip> at the top of your program (above or below #include<iostream>) and then right after you define your variables type:

cout << setprecision(2) << fixed;

Save this program as lab2a.cpp. Make sure your program compiles and runs like the sample output below.

Sample OutpuT

Amount paid for the stock: $26250.00

Commission paid on the sale: $525.00

Total amount paid for stock: $26775.00

STEP TWO: energy drink program

Image copied from https://makeameme.org/meme/im-telling-u-p2xy7a

DESCRIPTION / SPECIFICATIONS

This program was taken from page 82, Exercise 2-18 in the book Starting out with C++ From Control Structures through Objects by Tony Gaddis. A soft drink company recently surveyed 16,500 of its customers and found that approximately 15 percent of those surveyed purchase one or more energy drinks per week. Of those customers who purchase energy drinks, approximately 58 percent of them prefer citrus-flavored energy drinks. Write a program that displays the following:

  • The approximate number of customers in the survey who purchase one ore more energy drinks per week
  • The approximate number of customers in the survey who prefer citrus-flavored energy drinks

You should always end up with a whole person.

Save this program as lab2b.cpp. Make sure your program compiles and runs like the sample output below.

SAMPLE OUTPUT

Num of people who drink more than one a week: 2475

Num of people who drink more than one a week and prefer Citrus flavored: 1436

STEP THREE: MARRIED-COUPLE NAMES

Image copied from https://www.boredpanda.com

Description / Specifications

Take the program given to you in ilearn named lab2c_given.cpp. Rename this file lab2c.cpp.

Pat Smith and Kelly Jones are engaged. This program shows the possible last name combinations once they get married (listing Pat first). Extend this program to print the two hyphenated last name options (Smith-Jones, and Jones-Smith). Also make sure to modify the author information in the comment to be yours and your partner’s names

SAMPLE OUTPUT

The yellow highlighted parts are user input and the green highlighted part is what you are adding to the code.

What is the first person’s first name?

Pat

What is the first person’s last name?

Smith

What is the second person’s first name?

Kelly

What is the second person’s last name?

Jones

Here are some common married-couple names:

Pat Smith and Kelly Jones

Pat and Kelly Smith

Pat and Kelly Jones

Pat Smith and Kelly Smith-Jones

Pat Smith and Kelly Jones-Smith

What to Turn In

Create a zip file containing the following .cpp files and upload it to the ilearn LAB 2 assignment folder.

  • lab2a.cpp
  • lab2b.cpp
  • lab2c.cpp
CSC1300: LAB 2
$30.00 $24.00