- #1
Townsend
- 232
- 0
I am getting an error I cannot seem to figure out. whenever I try to compile it, it says c is undeclared. I want to check a type char variable against letters of the alphabet in an if function. Maybe someone could explain what I am doing wrong.
Of course the program is not finished yet but I need to fix this problem before I go any futher.
Thanks in advance
Townsend
Code:
#include <iostream>
#include <cctype>
//Prototype Declaration
void caseOne (char& vehicle);
//Prototype Declaration
void caseTwo (char& vehicle);
using namespace std;
int main()
{
char vehicle; //vehicle type
int hourEnter=0; //Hour entered lot
int minuteEnter=0; //minute entered lot
int hourLeft=0; //Hour left lot
int minuteLeft=0; //minute left lot
int r=0; //dummy variable
cout<<endl<<endl<<endl
<<"Please enter the type of "
<<"vehicle you drive. "
<<endl<<endl
<<"Please enter C for car, "
<<"B for bus and T for truck."
<<endl<<endl;
cin>>vehicle;
int islower(vehicle);
if (islower=1)
{
r=1;
}
else
r=2;
switch (r)
{
case 1: caseOne (vehicle);
break;
case 2: caseTwo (vehicle);
break;
default: cout<<endl<<endl
<<"Input error please start over.";
break;
}
cout<<endl<<endl
<<"Please enter the hour, between 0 and 23,"
<<" that you entered the lot."
<<endl<<endl;
cin>>hourEnter; //Prompt user for hour
cout<<endl<<endl
<<"Please enter the minute, between 0 and 59, "
<<"that you entered the lot."
<<endl<<endl;
cin>>minuteEnter;
cout<<endl<<endl
<<"Please enter the hour, between 0 "
<<"and 23, that you left the lot."
<<endl<<endl;
cin>>hourLeft;
cout<<endl<<endl
<<"Please the minute, between 0 and 59, "
<<"that you left the lot."
<<endl<<endl;
cin>>minuteLeft;
cout<<endl<<endl //program output
<<"\tPARKING LOT CHARGE"
<<endl<<endl
<<"Type of vehicle: "
<<vehicle
<<"\t\tTIME-IN "
<<endl
<<" "
<<"\t\t "
<<hourEnter<<minuteEnter
<<endl<<endl<<endl;
return 0;
} //main
/*================================caseOne=======================================
Determines type of vehicle from user input
Pre veh contains vehicle type to be determined
post nothing
*/
void caseOne (char& vehicle)
{
char x=c;
char y=b;
char z=t;
if (vehicle==x)
{
vehicle=Car;
}
else if (vehicle==y);
{
vehicle=Bus;
}
else if (vehicle==z)
{
vehicle=Truck;
}
return;
}
/*================================caseTwo=======================================
Determines type of vehicle from user input
Pre veh contains vehicle type to be determined
post nothing
*/
void caseTwo (char$ vehicle)
{
if (vehicle==C)
{
vehicle=Car;
}
else if (vehicle==B)
{
vehicle=Bus;
}
else if (vehicle==T)
{
vehicle=Truck;
}
return;
}
Of course the program is not finished yet but I need to fix this problem before I go any futher.
Thanks in advance
Townsend