Computing & Information Systems    Department Search CIS Site      Tutorials

## Software Design Using C++

### Review of Functions and Parameters

Your rewrite of the CalculateCost function was as follows. Choose from the list below of possible answers for a correct and compatible rewrite of the Results function.

 `````` float CalculateCost(float Price, int NumPurchased) { float TempCost; TempCost = Price * NumPurchased; if (TempCost > 80.0) TempCost = TempCost - 5.0; return TempCost; } ``````

 `````` void Results(float Price, int NumPurchased, float TotalCost) { float Cost; Cost = CalculateCost(Price, NumPurchased); TotalCost = TotalCost + Cost; cout << "Unit price: " << Price << " Number purchased: " << NumPurchased << " Cost: " << Cost << endl << endl; } ``````

 `````` void Results(float Price, int NumPurchased, float TotalCost) { float Cost; CalculateCost(Price, NumPurchased, Cost); TotalCost = TotalCost + Cost; cout << "Unit price: " << Price << " Number purchased: " << NumPurchased << " Cost: " << Cost << endl << endl; } ``````

 `````` void Results(float Price, int NumPurchased, float & TotalCost) { float Cost; Cost = CalculateCost(Price, NumPurchased); TotalCost = TotalCost + Cost; cout << "Unit price: " << Price << " Number purchased: " << NumPurchased << " Cost: " << Cost << endl << endl; } ``````

 `````` void Results(float Price, int NumPurchased, float & TotalCost) { float Cost; CalculateCost(Price, NumPurchased, Cost); TotalCost = TotalCost + Cost; cout << "Unit price: " << Price << " Number purchased: " << NumPurchased << " Cost: " << Cost << endl << endl; } ``````