New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

CPT 234 Week 4

by: Lukas Notetaker

CPT 234 Week 4 CPT 234

Lukas Notetaker
GPA 3.903

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

These notes cover the homework assignment
C Programming I
George Edward Fiori
Class Notes
C, c++
25 ?




Popular in C Programming I

Popular in Computer Programming

This 3 page Class Notes was uploaded by Lukas Notetaker on Sunday September 11, 2016. The Class Notes belongs to CPT 234 at Tri-County Technical College taught by George Edward Fiori in Fall 2016. Since its upload, it has received 4 views. For similar materials see C Programming I in Computer Programming at Tri-County Technical College.


Reviews for CPT 234 Week 4


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/11/16
// Programmer : Lukas Herman // Date : 09/09/2016 // Program Name : Chapter 2 - Stock Purchase // Chapter : Chapter 2 - Fundamentals // Description : The program calculates the amount of profit or loss earned by the user's transaction with the broker. // At first, the program will ask required informations (buying and selling): number of shares, // price per share, and commission rate. Then the program will process all the data by applying // simple business formulas. #include <stdio.h> int main() { // *** Constant and Variable Declarations *** // === Buying Program's Constant and Variable Declarations === int numBoughtShares = 0; double buyingPricePerShare = 0.0; double buyingCommissionRate = 0.0; double buyingPriceBeforeComission = 0.0; double totalBuyingPrice = 0.0; double buyingCommissionPrice = 0.0; // === Selling Program's Constant and Variable Declarations === int numSoldShares = 0; double sellingPricePerShare = 0.0; double sellingCommissionRate = 0.0; double sellingPriceBeforeComission = 0.0; double totalSellingPrice = 0.0; double sellingCommissionPrice = 0.0; double profit = 0.0; // === Buying Program Starts Here === // *** Input *** printf_s("Enter the number of shares of stock purchased: "); scanf_s("%d", &numBoughtShares); printf_s("Enter the purchase price for 1 share of the stock: $"); scanf_s("%lf", &buyingPricePerShare); printf_s("Enter the commission rate to purchase the stock: "); scanf_s("%lf", &buyingCommissionRate); // A blank line printf_s("\n"); // *** Procession *** buyingPriceBeforeComission = numBoughtShares * buyingPricePerShare; buyingCommissionPrice = buyingCommissionRate / 100 * buyingPriceBeforeComission; totalBuyingPrice = buyingPriceBeforeComission + buyingCommissionPrice; // *** Output *** printf_s("You purchased %d shares of stock at $%.2lf per share\n", numBoughtShares, buyingPricePerShare); printf_s("for a cost of $%.2lf.\n", buyingPriceBeforeComission); printf_s("The commission for the purchase at %.2lf%% was $%.2lf,\n", buyingCommissionRate, buyingCommissionPrice); printf_s("for a total price of $%.2lf\n", totalBuyingPrice); // A blank line printf_s("\n"); // === Buying Program Ends Here === // === Selling Program Starts Here === // *** Input *** printf_s("Enter the number of shares of stock sold: "); scanf_s("%d", &numSoldShares); printf_s("Enter the selling price for 1 share of the stock: $"); scanf_s("%lf", &sellingPricePerShare); printf_s("Enter the commission rate to sell the stock: "); scanf_s("%lf", &sellingCommissionRate); // A blank line printf_s("\n"); // *** Procession *** sellingPriceBeforeComission = numSoldShares * sellingPricePerShare; sellingCommissionPrice = sellingCommissionRate / 100 * sellingPriceBeforeComission; totalSellingPrice = sellingPriceBeforeComission - sellingCommissionPrice; // *** Output *** printf_s("You sold %d shares of stock at $%.2lf per share for $%.2lf.\n", numSoldShares, sellingPricePerShare, sellingPriceBeforeComission); printf_s("The commission for the sale at %.2lf%% was $%.2lf,\n", sellingCommissionRate, sellingCommissionPrice); printf_s("for a total price of $%.2lf\n", totalSellingPrice); // A blank line printf_s("\n"); // === Selling Program Ends Here === // === Profit Program Starts Here === // *** Procession *** profit = totalSellingPrice - totalBuyingPrice; // *** Output *** printf_s("The amount of profit (or loss) earned by this transaction was $ %.2lf.\n", profit); // A blank line printf_s("\n"); return 0; } // end main()


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Jennifer McGill UCSF Med School

"Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over $500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.