Ok so for an assignment we have to make our first program. Mine is to make a program that calculates the ticket revenue for each seating section at a theater. The problem is that I keep getting this undeclared identifier or identifier undefined error along with like 23 other errors. The program I am using is Visual Studio 2010 Premium.
Here is my code.
// Chp4HWprgm.cpp
// Created by Bryce Easley on 2/6/2012
#include <iostream>
using namespace std;
int main(){
//declare variables
int orchestraNum = 0;
int mainNum = 0;
int balconyNum =0;
const orchestraPrice = 25;
const mainPrice = 30;
const balconyPrice = 15;
//enter input of sales
cout << "Number of Orchestra tickets sold?";
cin >> orchestraNum;
cout << "Number of Main Floor tickets sold?";
cin >> mainNum;
cout << "Number of Balcony tickets sold?";
cin >> balconyNum;
//calculate revenue for each and total revenue
orchestraTotal = orchestraNum * orchestraPrice;
mainTotal = mainNum * mainPrice;
balconyTotal = balconyNum * balconyPrice;
overallTotal = mainTotal + balconyTotal + orchestraTotal;
//display figures
cout <<"Orchestra Revenue: $" << orchestraTotal << endl;
cout <<"Main Floor Revenue: $" << mainTotal << endl;
cout <<"Balcony Revenue: $" << balconyTotal << endl;
cout <<"Overall Revenue: $" << overallTotal << endl;
system("pause");
return 0;}
//end of main function
Here are my errors:
Error 6 error C2065: 'balconyTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 28 1 Chapter4HW Error 9 error C2065: 'balconyTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 29 1 Chapter4HW Error 13 error C2065: 'balconyTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 34 1 Chapter4HW Error 5 error C2065: 'mainTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 27 1 Chapter4HW Error 8 error C2065: 'mainTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 29 1 Chapter4HW Error 12 error C2065: 'mainTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 33 1 Chapter4HW Error 4 error C2065: 'orchestraTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 26 1 Chapter4HW Error 10 error C2065: 'orchestraTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 29 1 Chapter4HW Error 11 error C2065: 'orchestraTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 32 1 Chapter4HW Error 7 error C2065: 'overallTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 29 1 Chapter4HW Error 14 error C2065: 'overallTotal' : undeclared identifier c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 35 1 Chapter4HW Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 13 1 Chapter4HW Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 14 1 Chapter4HW Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 15 1 Chapter4HW 15 IntelliSense: explicit type is missing ('int' assumed) c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 13 7 Chapter4HW 16 IntelliSense: explicit type is missing ('int' assumed) c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 14 7 Chapter4HW 17 IntelliSense: explicit type is missing ('int' assumed) c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 15 7 Chapter4HW 20 IntelliSense: identifier "balconyTotal" is undefined c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 28 1 Chapter4HW 19 IntelliSense: identifier "mainTotal" is undefined c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 27 1 Chapter4HW 18 IntelliSense: identifier "orchestraTotal" is undefined c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 26 1 Chapter4HW 21 IntelliSense: identifier "overallTotal" is undefined c:\users\bryce\desktop\cpp6\chap04\chapter4hw\chapter4hw\chp4hw.cpp 29 1 Chapter4HW
Gracias to everyone that answered. I seriously stared at this forever and I couldnt figure it out. It's like learning a whole new language and it's a bit confusing!