I have a problem for my class, and I've run into a really weird problem.
So the problem is a travel expense problem, where I need to use a for-loop to ask the user a few questions, such as cost of hotel, cost of parking fee, cost of bridge toll.
So anyhow here's a snippet of my code:
Code:
#include <iostream>
using namespace std;
int main()
{
double dhotel, dmeal, dpark, dbridge, dmiles, dtemp = 0.0;
string scar; // Car name
int iyear; // Car year
string scolor; // Car color
string smake; // Car make
int i = 0;
int iSize = 0;
int iCounter = 0;
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
cout << "Enter number of hotels you visited: ";
cin >> iSize;
for ( i = 0; i < iSize; i++ )
{
iCounter++;
cout << "\nEnter total cost of hotel "
<< iCounter
<< ": $ ";
cin >> dtemp;
dhotel += dtemp;
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
cout << "\nTotal cost of hotel: $ "
<< dhotel;
return 0;
}
Output
--------
Enter number of hotels you visited: 2
Enter total cost of hotel 1: $ 1.00
Enter total cost of hotel 2: $ 1.00
Total cost of hotel: $ 0.00162506
![Confused](/tfp/images/smilies/confused.gif)
What's going on here?