temperoath
Programmer
Im a C++ student trying to write a simple telephone program. Im sure you guys can figure this out.
heres my code. When I compile I get "error C2041: illegal digit '8' for base '8'" on the first if statement.
#include <iostream>
using namespace std;
float net(float, int);
float gross;
int main()
{
float start = 0;
int length = 0;
cout<<"Please enter a start time based on a 24 hour clock (i.e 1800 = 6:00pm):"<<endl;
cin>>start;
cout<<"Please enter the length of the call:"<<endl;
cin>>length;
gross = length * 0.10;
cout<<"The gross cost of this call before any discounts is: "<<gross<<endl;
float net(float start, int length);
cout<<"The net cost after all dicounts and including tax is: "<<net<<endl;
return 0;
}
float net(float start, int length)
{
float discount1;
float discount2;
float net;
if (start >= 1800 && start <= 0800)
discount1 = gross * 0.50;
if (length >= 60)
discount2 = gross * .15;
net = gross - discount1 - discount2;
net = (net * 0.04) + net;
return net;
}
heres my code. When I compile I get "error C2041: illegal digit '8' for base '8'" on the first if statement.
#include <iostream>
using namespace std;
float net(float, int);
float gross;
int main()
{
float start = 0;
int length = 0;
cout<<"Please enter a start time based on a 24 hour clock (i.e 1800 = 6:00pm):"<<endl;
cin>>start;
cout<<"Please enter the length of the call:"<<endl;
cin>>length;
gross = length * 0.10;
cout<<"The gross cost of this call before any discounts is: "<<gross<<endl;
float net(float start, int length);
cout<<"The net cost after all dicounts and including tax is: "<<net<<endl;
return 0;
}
float net(float start, int length)
{
float discount1;
float discount2;
float net;
if (start >= 1800 && start <= 0800)
discount1 = gross * 0.50;
if (length >= 60)
discount2 = gross * .15;
net = gross - discount1 - discount2;
net = (net * 0.04) + net;
return net;
}