Question
#include #include int main() { //Declare variables char name[10]; int shares; float buy_price, current_price, yearly_fees; float initial_cost, current_cost, profit; //Ask user for informations printf(Enter Stock
#include
int main() { //Declare variables char name[10]; int shares; float buy_price, current_price, yearly_fees; float initial_cost, current_cost, profit;
//Ask user for informations printf("Enter Stock Name: "); gets(name); printf("Enter Number of Shares: "); scanf("%d", &shares); printf("Enter Buy Price: "); scanf("%f", &buy_price); printf("Enter Current Price: "); scanf("%f", ¤t_price); printf("Enter Yearly Fees: "); scanf("%f", &yearly_fees);
//Calculation initial_cost = shares * buy_price; current_cost = shares * current_price; profit = current_cost - initial_cost - yearly_fees;
//Print out according to information user entered printf(" The Stock name\t %s", name); printf(" Initial Cost\t $ %0.2f", initial_cost); printf(" Current Cost\t $ %0.2f", current_cost); printf(" Profit\t\t $ %0.2f", profit);
return 0; }
I did this so far. But i need help about printing the total profit of 5 company.
Program Set 4 You need a program to maintain information about your stocks. Assume that you have the following stocks: Stock Name Yearly Fees BM Number of Shares 150 215 355 75 ORACLE SUN MICRO LINKSYS CISCO Buying Price Per Share $11.33 $10.77 $25.65 $2234 $45.36 Current Price Per Share $13.33 $12 25 $35.75 $23 34 $50.86 $5.00 $3.50 $12.25 $0.00 $1.50 Write a C program that will perform the following tasks: Task 1: Allow the user to enter in the data for each stock. Stock name, Number of shares, Buy Price Current Price and Yearly fees (The user will not enter the Ss.) Task 2: Calculate the initial Cost Current Cost and Profit for each stock. The formulas to use are: Initial Cost = Number of Shares Buying Price Per Share Current Cost = Number of Shares Current Price Per Share Profit = Current Cost - Initial Cost - Yeariy Fees Task 3: Print out the Stock Name. Initial Cost, Current Cost and Profit for each stock Task 4: Calculate and print the total profit for all of the stocks. That is find the sum of the 5 profits for each stock
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started