Please help. What am I doing wrong?

I keep getting this error : TP.cc:18: error: line extends beyond 80 columns

This is my code;

#include <iostream>
using namespace std;

int main()
{

char get_call_period; // To get Call period D/day E/Evening W/NightNWknds
double get_call_duration; // To get call duration in minutes and seconds.
double compute_call_cost; // To calculate the cost of the call.
double report_call_cost; // Report the total converted cost back to the user.

//This will display the company of the telephone service as well as the version,
// and my name, copyright, and date.

cout << "High-Strung Long-Distance Telephone Service Program, version 1.0" << endl;
cout << "(C) Josh Preston " << " 2011" << endl;
cin >> get_call_period;
cout << "Enter the duration of the call in minutes: " << endl;
cin >> get_call_duration;
cout << "Your " << get_call_duration << "minute " << get_call_period <<
"call will cost: " << report_call_cost << endl;

// Determine the period of the call and calculate for Nights and Weekends.

if (get_call_period == 'W')
{
report_call_cost = (get_call_duration * .4);
else
}

if (get_call_period == 'D')
{
if (get_call_period > 0 && get_call_period <=3)
{
report_call_cost = (get_call_period + .33);
else
}
report_call_cost = (get_call_duration * 9);
else
}
if (get_call_period == 'E')
{
report_call_cost = (get_call_period * 7);
else

return 0;
}



Are you by any chance using an ancient compiler?
I'm using PuTTy and compiling in that? Should it matter how many lines I have? I'm so confused
No it shouldn't matter. I have heard something about 80 columns limitations but maybe that was just to fit the code in screen in the old days. That's why I asked.

Looking at the code you have some problems with the else keyword. You use of else doesn't make sense to be honest.
Last edited on
Ok I got it to compile and this is the error I received. What am I diong wrong?

TP.cc:15:9: error: missing terminating " character
TP.cc:15: error: missing terminating " character
TP.cc: In function âint main()â:
TP.cc:29: error: expected `}' before âelseâ
TP.cc:30: error: expected primary-expression before â}â token
TP.cc:30: error: expected `;' before â}â token
TP.cc: At global scope:
TP.cc:32: error: expected unqualified-id before âifâ
You declared compute_call_cost and report_call_post as two variables instead of functions.
Also wrong use of else.
Why do you add a fraction to a char?
I am confused by the code, why this version compiles.
#include <iostream>
using namespace std;

int main()
{
char get_call_period; // To get Call period D/day E/Evening W/NightNWknds
double get_call_duration; // To get call duration in minutes and seconds.
double compute_call_cost; // To calculate the cost of the call.
double report_call_cost; // Report the total converted cost back to the user.

cout << "High-Strung Long-Distance Telephone Service Program, version 1.0" << endl;
cout << "(C) Josh Preston " << " 2011" << endl;
cin >> get_call_period; //not sure whether cin suits
cout << "Enter the duration of the call in minutes: " << endl;
cin >> get_call_duration;

if (get_call_period == 'W')
report_call_cost = (get_call_duration * .4);
else if (get_call_period == 'D')
{
if (get_call_period > 0 && get_call_period <=3)
report_call_cost = (get_call_period + .33); //isn't period a char? why do you add a fraction to it?
else
report_call_cost = (get_call_duration * 9);
}
else if (get_call_period == 'E')
report_call_cost = (get_call_period * 7);
else if (get_call_period == 'N')
report_call_cost = 0; // not sure what you mean.
else
cerr << "Wrong call period." << endl;
//This will display the company of the telephone service as well as the version,
// and my name, copyright, and date.

cout << "Your " << get_call_duration << "minute " << get_call_period <<
"call will cost: " << report_call_cost << endl;

// Determine the period of the call and calculate for Nights and Weekends.
return 0;
}
TP.cc:15:9: error: missing terminating " character
TP.cc:15: error: missing terminating " character
TP.cc: In function âint main()â:
TP.cc:31: error: expected `}' before âelseâ
TP.cc:32: error: expected primary-expression before â}â token
TP.cc:32: error: expected `;' before â}â token
TP.cc: At global scope:
TP.cc:34: error: expected unqualified-id before âifâ
Topic archived. No new replies allowed.