i want it to tell me it is impossible to have more than 744 hours however if i input 744 or anything above it, it is just calculated as a price like the other 2 options. how do i code it so it says that it is too much?
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
cout << "Which package did you purchase?: A, B, or C?\n(A/B/C)\n\n";
char pack;
cin >> pack;
switch (pack)
{
case'a': cout << "\nyou picked A.\n\nHow many hours were you on the internet?:\n\n";
float A_nethours;
cin >> A_nethours;
if (A_nethours <= 10)
{ cout << "\nyou have a bill of 9.95 in your account because you did not go over the limit.\n";
}
elseif (A_nethours > 10)
{
cout << "\nYou have a bill of " << (A_nethours - 10.00) * 2.00 + 9.95 << " in your account because of extra fees.\n";
}
elseif (A_nethours > 744) // <-----problem here
{
cout << "\nThat is impossible.";
}
else
{
cout << "\nInvalid answer.";
}
break;
case'b': cout << "\n\nyou picked B.\n";
break;
case'c': cout << "\n\nyou picked C.\n";
break;
default: cout << "Not a valid answer.";
}
cin.get();
cin.get();
cin.get();
}
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
cout << "Which package did you purchase?: A, B, or C?\n(A/B/C)\n\n";
char pack;
cin >> pack;
switch (pack)
{
case'a': cout << "\nyou picked A.\n\nHow many hours were you on the internet?:\n\n";
float A_nethours;
cin >> A_nethours;
if (A_nethours <= 10)
{ cout << "\nyou have a bill of 9.95 in your account because you did not go over the limit.\n";
}
elseif (A_nethours > 10)
{
// edited this area ----
if (A_nethours <= 744)
{
cout << "\nYou have a bill of " << (A_nethours - 10.00) * 2.00 + 9.95 << " in your account because of extra fees.\n";
}
elseif (A_nethours > 744)
{
cout << "\nThat is impossible.";
}
else
{
cout << "\nInvalid answer.";
}
} // ----
break;
case'b': cout << "\n\nyou picked B.\n";
break;
case'c': cout << "\n\nyou picked C.\n";
break;
default: cout << "Not a valid answer.";
}
cin.ignore(); cin.get(); // also edited this(in place of the 3 cin.get()s)
}