C++ tip Calc

Hi guys, I made a tip calculator and there is one error;, here is the code.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream.h>

int main() 
{
    double bill, tip; 
    int split; 
    cout<<"enter your bill: ";
    cin>>bill;
    while (bill<0)
    {
          cout<<"You can't have a bill less than 1 cent. Enter your bill again: "; 
          cin>>bill; 
}
    cout<<"Enter the percent you want to tip with: "; 
    cin>>tip; 
    while(tip<0)
    {
                cout<<"You can't give negative tip percent. Enter tip percent again: ";
                cin>>tip;
}
    cout<<"enter how many people are splitting the bill: "; 
    cin>>split;
    while(split<1) 
    {
                   cout<<"You can't pay with less than one person. Enter number of people again: "; 
                   cin>>split; 
     }
     cout<<endl; 
     cout<<"Your tip is: "<< bill (tip/100) << "dollars"<<endl; 
     cout<<"your total price is: "<< bill + (bill+tip/100) <<" dollars"<<endl; 
     cout<<"each person should pay: "<< (bill + (bill*tip/100) ) / split <<"dollars"<<endl; 
     system("Pause"); 
     return 0; 
     }
     


It says the 1st line has an error and won't compile and run..here is the error

1 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from C:\Users\NightJay0044\Desktop\tip1.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from C:\Users\NightJay0044\Desktop\tip1.cpp

Something with the iostream?

Thank you..




Remove the .h from #include <iostream>

Also, you may want to consider putting using namespace std; to avoid changing all of your code.

Additionally, on line 9, you may have meant <= and not <
Last edited on
@L B
Thanks, yeah that worked with excluding the h and adding namespace.

Thanks
Topic archived. No new replies allowed.