title: Getting wrong output. Garbage value
body: <p>Problem is, on execution, the value of <code>roundCost</code> I'm getting is
  something like -1220673834. I post the entire program because I'm not
  sure where I'm going wrong.</p>
  
  <p>Note: I was asked to take all variables as <code>double</code> type and later,
  <code>roundCost</code> should be of type <code>int</code>. So I used type conversion there.</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  class Restaurant{ 
  
  private:
  double tip, tax,totalCost,mealCost, tipPercent, taxPercent;
  int roundCost;
  public:
  
  int tipCalc(double)
      {
      tip=mealCost*(tipPercent/100);
      return tip;
      }
  
  int taxCalc(double)
      {
      tax=mealCost*(taxPercent/100);
      return tax;
      }
  
  int totalCost1()
      {
      totalCost=mealCost+tip+tax;
      return totalCost;
      }
  
  int roundCost1(double)
      {
      roundCost=(int)totalCost;
      return roundCost;
      }   
  
  
  }; // class ends
  int main()
  {
  double mealCost, tipPercent, taxPercent, totalCost;
  int roundCost;
  
  Restaurant ob1;
  
  cout&lt;&lt;"\n Enter mealCost \n";
  cin&gt;&gt;mealCost;
  cout&lt;&lt;"\n Enter mealtipPercent \n";
  cin&gt;&gt;tipPercent;
  cout&lt;&lt;"\n Enter mealtaxPercent \n";
  cin&gt;&gt;taxPercent;
  ob1.tipCalc(tipPercent);
  ob1.taxCalc(taxPercent);
  ob1.totalCost1();
  ob1.roundCost1(totalCost);
  cout&lt;&lt;"\n Round of cost is "&lt;&lt;roundCost&lt;&lt;endl;
  return 0;
  }
  </code></pre>