Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

functions and parameter passing only no Struck Write a c++ program which uses ap

ID: 3883522 • Letter: F

Question

functions and parameter passing only no Struck Write a c++ program which uses appropriate functions and parameter passing that will perform the folowing tasks: Write a c++ program which uses appropriate functions and parameter passing that will perform the folowing tasks: Exam 1 Program: You need a program to maintain information about your stocks. the following stocks: Assume that you have Stock Name Number of Buying Price Current PriceYearly Fees Shares GREAT ONE 275 BORING LAKERS IVC SADDLEBACK 80 Per Share $22.33 $15.75 $35.55 $22.36 $12.76 Per Share $42.33 $15.75 $19.75 $25.44 $10.86 $4.00 $0.00 $11.25 $8.00 $10.50 150 200 175 Write a C++ program which uses appropriate functions and parameter passing that will perform the following tasks: Task 1: Allow the user to enter in the data for each stock. (The user will not enter the $'s.) Task 2: Calculate the Initial Cost, Current Cost, and Proft 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-Yearly Fees Task 3: Print out the Stock Name, Initial Cost, Current Cost, and Profit for each stock Task 4: Calculate and print the total initial cost, total current cost, and total profit for all 5 stocks Task 5: Print out the number of stocks that had a positive profit, the number of stocks that had a negative profit, and the number of stocks that broke even, that is had a profit of $0.00.

Explanation / Answer

Here is your C++ Stock Program:

C++ Program:

#include<iostream>

#include<conio.h>

#include<string>

using namespace std;

float InitialCost[5],CurrentCost[5],Profit[5];

string StockName[]={"GREAT ONE","BORING","LAKERS","IVC","SADDLEBACK"};

float BuyingPrice[]={22.33,15.75,35.55,22.36,12.76};

float CurrentPrice[]={42.33,15.75,19.75,25.44,10.86};

float YearFee[]={4,0,11.25,8,10.50};

void AllCost(int NoOfShares,int index)//This is Task 2

{

InitialCost[index]=NoOfShares*BuyingPrice[index];

CurrentCost[index]=NoOfShares*CurrentPrice[index];

Profit[index]=CurrentCost[index]-InitialCost[index]-YearFee[index];

}

void printCosts()// This is Task 3

{

for(int i=0;i<5;i++)

{

cout<<" "<<StockName[i]<<" "<<InitialCost[i]<<" "<<CurrentCost[i]<<" "<<Profit[i];

}

}

void printTotalCost()//This is Task 4

{

float TICost=0,TCCost=0,TProfit=0;

for(int i=0;i<5;i++)

{

TICost+=InitialCost[i];

TCCost+=CurrentCost[i];

TProfit+=Profit[i];

}

cout<<" Total Inital Cost "<<TICost;

cout<<" Total Current Cost "<<TCCost;

cout<<" Total Profit "<<TProfit;

}

void printProft()//This is Task 5

{

int posProfit=0,negProfit=0,even=0;

for(int i=0;i<5;i++)

{

if(Profit[i]>0)

posProfit++;

if(Profit[i]<0)

negProfit++;

if(Profit[i]==0)

even;

}

cout<<" Total Positibe Profit stock "<<posProfit;

cout<<" Total Negetive Profit Stock "<<negProfit;

cout<<" Total Even Profit Stock "<<even;

}

void main()

{

int n;

for(int i=0;i<5;i++)//This is Task 1

{

cout<<"Enter no of shares for "<<StockName[i]<<" ";

cin>>n;

AllCost(n,i);

}

printCosts();

cout<<" ";

printCosts();

cout<<" ";

printTotalCost();

cout<<" ";

printProft();

getch();

}

I hope this solves your problem

Comment if you have any problem in above code

And please give it a thumbs up if it solved your problem :)