CIS Logo SVC Logo

   Computing & Information Systems
   Department

 

Schoology Facebook        Search CIS Site      Tutorials

Software Design Using C++



Review of Functions and Parameters



Answering the Question


Let's first rewrite the CalculateCost function. Here are possible answers to this. Click on the one that you think is the best solution.
  • Answer A

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

  • Answer B

    
    void CalculateCost(float & Price, int & NumPurchased, float & Cost)
       {
       Cost = Price * NumPurchased;
       if (Cost > 80.0)
          Cost = Cost - 5.0;
       }
    

  • Answer C

    
    void CalculateCost(float Price, int NumPurchased, float Cost)
       {
       Cost = Price * NumPurchased;
       if (Cost > 80.0)
          Cost = Cost - 5.0;
       }
    

  • Answer D

    
    void CalculateCost(float Price, int NumPurchased, float & Cost)
       {
       Cost = Price * NumPurchased;
       if (Cost > 80.0)
          Cost = Cost - 5.0;
       }
    

You can go back to the overall review listing: Review of Introductory Topics.

Back to the main page for Software Design Using C++

Author: Br. David Carlson with contributions by Br. Isidore Minerd
Last updated: January 15, 2013
Disclaimer