-
January 30th, 2009, 10:42 AM
#1
Code Help Please
Im getting two errors on my program, Im new to C++ programming and wondering if anyone could help
error C2065: 'Ssales' : undeclared identifier
fatal error C1903: unable to recover from previous error(s); stopping compilation
I believe the 2nd error is due to the first, but i could be wrong.
Im trying to make my program do the SalesDayLoop function when the customer responds yes, but its says it undeclared but it is declared im lost any help thanks guys
[code]
/*Program: PaintModule
Programmer: Nathan Marcarelli
Date: 01/22/09
Prgoram:ModuleProgram.cpp
Version:1
*/
/*-------------------------PREPROCESSING DIRECTIVES-----------------------------------------------------*/
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <cstdlib>
using namespace std;
/*-------------------------FUNCTION PROTOTYPES----------------------------------------------------------*/
void GetRoomDimensions(void);
void PerformCalc(void);
void PrintOutput(void);
void GetName(void);
void RepeatCode (void);
void Loop (void);
void DisplayNameHeader(void);
void Dashes(void);
void SalesDay (void);
void DisplayHeader(void);
void SalesDayLoop(void);
/*-----------------------Global Variables--------------------------------------------------------------*/
//input variables
float Flength;
float Fwidth;
float Fheight;
char sCname[25];
char sRepeat='Y' ;
char sSales='Y' ;
//Calculated Data
float Farea; // = wall 1 + wall 2
float Fwall1; // Length * Height *2
float Fwall2; // Width * Height *2
float Fareagallon; // Amount of area a gallon will cover
float Fgallons; // Total Number of gallons it will take to paint
float Ftotalprice; //Final Cost
float Fcostper; //Cost per gallon of paint
/*--------------------Main Module------------------------------------------------------------------*/
int main ()
{
SalesDay();
while (Ssales=='Y');
do
{
SalesDayLoop();}
GetName();
do
{
RepeatCode();
}while (sRepeat=='Y');
GetRoomDimensions();
PerformCalc();
PrintOutput();
Loop();
system("pause");
return 0;
}
/*-----------------------------------------------------------------------------------------------------
Name: Sales Day
Desc: Asks User if It is a Sales Day
Return: Void
Parameters: Void
---------------------------------------------------------------------------------------------------*/
void SalesDay (void)
{
Dashes();
cout<<setw(56)<<"Welcome to the Acme Paint Shop ";
cout << endl;
Dashes();
cout << endl;
cout <<"Is today a sales day (Y/N)?";
cin >> sSales;
system("cls");
return;
}
/*-----------------------------------------------------------------------------------------------------
Name: GetName
Desc: Gets Name
Return: Void
Parameters: Void
---------------------------------------------------------------------------------------------------*/
void GetName (void)
{
DisplayHeader();
cout << endl;
cout<<"Enter the customer's first and last name?";
cin.getline(sCname, 25);
return;
}
/*-----------------------------------------------------------------------------------------------------
Name: GetRoomDimensions
Desc: Gets Room Dimensions
Return: Void
Parameters: Void
---------------------------------------------------------------------------------------------------*/
void GetRoomDimensions(void)
{
cout<<"What is the length of the room in feet?";
cin>> Flength ;
cout<<"What is the width of the room in feet?";
cin>>Fwidth;
cout<<"What is the height of the room in feet?";
cin>>Fheight;
cout <<"What is the area covered by a gallon of paint?";
cin>>Fareagallon;
cout <<"What is the cost of paint per gallon?";
cin >> Fcostper;
return;
}
/*---------------------------------------------------------------------------------------------------------
Name:PerformCalc
Desc:Calculate Area
Return: Void
Parameters:Void
----------------------------------------------------------------------------------------------------------*/
void PerformCalc (void)
{
Fwall1 = (Flength * Fheight)* 2;
Fwall2 = (Fwidth * Fheight) * 2;
Farea = (Fwall1+ Fwall2);
Fgallons = Farea/Fareagallon;
Ftotalprice = ceil(Fgallons) * Fcostper;
return;
}
/*-----------------------------------------------------------------------------------------------------------
Name:PrintOutput
Descisplay Output on Monitor
Return:Void
Parameter: Void
------------------------------------------------------------------------------------------------------------*/
void PrintOutput (void)
{
DisplayHeader();
cout <<endl;
cout<<sCname;
cout<<endl;
cout <<"The area of the room is ";
cout <<Farea;
cout <<" feet.";
cout << endl;
cout <<"You need to purchase ";
cout <<ceil(Fgallons);
cout <<" Gallons of paint.";
cout <<endl;
cout <<"The total cost of paint is $";
cout <<Ftotalprice;
cout << endl;
return;
}
/*-----------------------------------------------------------------------------------------------------
Name: RepeatCode
Desc: Code Inside Loop
Return: Void
Parameters:
---------------------------------------------------------------------------------------------------*/
void RepeatCode ()
{
cout <<endl;
GetRoomDimensions();
PerformCalc ();
PrintOutput();
Loop();
DisplayHeader();
Dashes();
return;
}
/*-----------------------------------------------------------------------------------------------------------
Name:Loop
Desc:Loops Program
Return:Void
Parameter: Void
------------------------------------------------------------------------------------------------------------*/
void Loop (void)
{
cout<<endl;
cout <<"Do you want to continue (Y/N)?";
cin >>sRepeat;
sRepeat = toupper(sRepeat);
system("cls");
return;
}
/*-----------------------------------------------------------------------------------------------------------
Nameisplay Header
Descisplay Header
Return:Void
Parameter: Void
------------------------------------------------------------------------------------------------------------*/
void DisplayNameHeader (void)
{
system("cls");
cout<< "\n";
Dashes();
cout<<setw(40)<<"Welcome " <<sCname;
cout << endl;
return;
}
/*-----------------------------------------------------------------------------------------------------------
Nameashes
Descisplays Dashes
Return:Void
Parameter: Void
------------------------------------------------------------------------------------------------------------*/
void Dashes (void)
{
int iCounter=0;
for(iCounter = 0; iCounter <80; ++iCounter)
cout<< "*";
return;
}
/*-----------------------------------------------------------------------------------------------------------
NameisplayHearder
Descisplays Dashes Header
Return:Void
Parameter: Void
------------------------------------------------------------------------------------------------------------*/
void DisplayHeader(void)
{
Dashes();
cout<<setw(56)<<"Welcome to the Acme Paint Shop ";
cout << endl;
Dashes();
cout << endl;
return;
}
/*-----------------------------------------------------------------------------------------------------------
Name:SalesDayLoop
Desc:If it is a sales day it runs a sepearte function
Return:Void
Parameter: Void
------------------------------------------------------------------------------------------------------------*/
void SalesDayLoop (void)
{
DisplayHeader();
GetName();
GetRoomDimensions();
PerformCalc ();
PrintOutput();
Loop();
return;
}
[code]
-
January 30th, 2009, 10:45 AM
#2
-
January 30th, 2009, 10:54 AM
#3
Re: Code Help Please
Yes, GCDEF is correct. Ssales and sSales are two different variables.
-
January 30th, 2009, 10:54 AM
#4
Re: Code Help Please
Ya I knew that don't know why i didn't reconize that. Thanks man.
Update now it is saying error C2061: syntax error : identifier 'GetName'
Am i missing an opening or a closing bracket somewhere ?
Last edited by carvin317; January 30th, 2009 at 10:57 AM.
-
January 30th, 2009, 12:43 PM
#5
Re: Code Help Please
Update now it is saying error C2061: syntax error : identifier 'GetName'
Am i missing an opening or a closing bracket somewhere ?
-
January 30th, 2009, 12:52 PM
#6
Re: Code Help Please
do
{
SalesDayLoop();
}
GetName();
do requires while after the closing brace.
while (Ssales=='Y'); will loop indefinitely.
I'd recommend reading up on do and while and looping in general.
-
January 30th, 2009, 01:25 PM
#7
Re: Code Help Please
Originally Posted by carvin317
Am i missing an opening or a closing bracket somewhere ?
You are missing a / in the closing [code] (it should be [/code]!).
More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf
Premature optimization is the root of all evil --Donald E. Knuth
Please read Information on posting before posting, especially the info on using [code] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|