Quote:
string TV (char code, string title)
{
float cost = 0 ;
string type = "TV" ;
return type ;
return title ;
return cost ;
}
Sorry, I can't believe the compiler (and a human either) could accept the above code:
return cost;
is just plain wrong, the function must return a
string
instead of a
float
.
[update]
A working (though incomplete) code
#include <iostream>
using namespace std;
void Movie (char code, string title);
int main()
{
string title;
char code;
cout << "Enter the code of viewing and the title of the viewing. (Separated by a 11 space; either T, M, or N" << endl;
cin >> code >> title;
switch (code)
{
case 'M':
case 'm':
Movie(code, title);
break ;
default:
cout << "error" << endl ;
}
return 0 ;
}
void Movie (char code, string title)
{
int year ;
float cost ;
string type = "Movie" ;
cout << "Enter year of movie" << endl ;
cin >> year ;
if (year < 1960 )
{
cost = 2.99 ;
cout << title << endl ;
cout << type << endl ;
cout << "$" << cost << endl ;
}
else if (year < 1980)
{
cost = 3.99 ;
cout << type << endl ;
cout << "$" << cost << endl ;
}
else if (year < 2000)
{
cost = 4.99 ;
cout << title << endl ;
cout << type << endl ;
cout << "$" << cost << endl ;
}
else if (year > 2000)
{
cost = 5.99 ;
cout << title << endl ;
cout << type << endl ;
cout << "$" << cost << endl ;
}
else
{
cout << "No movies from the year 2000." << endl;
}
}
[/update]