GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Feb-2006, 16:46
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Compile errors


Arggh...... just can't figure out why I can't compile this damn thing. Just a straightahead nested if statement.......

CPP / C++ / C Code:
#include <iostream>
using namespace std;

int main () 
{
	float heading;	//Input - compass heading
	float bearing;
	
	cout << "Enter compass heading:";
	cin >> heading;
	
	if ((heading < 0.0) || (heading > 360.0))	//Checks to see if heading entry is in valid range
	{
		cout << "Invalid compass heading!" << endl;	//Output error message
	}
	
	else if (heading < 90.0)	//Checks to see if heading is between 0 -  <90 degrees
	{
		bearing = (90.0 - heading);
		cout << "North " << bearing << " degrees East." << endl;	//Output compass bearing
	}
		
	eise if (heading < 180.0)	//Checks to see if heading is between 90 - <180 degrees
	{
		bearing = (180.0 - heading);
		cout << "South " << bearing << " degrees East." << endl;	//Output compass bearing
	}
		
	else if (heading < 270.0)	//Checks to see if heading is between 180 - <270 degrees
	{
		bearing = (270.0 - heading);
		cout << "South " << bearing << " degrees West." << endl;	//Output compass bearing
	}
		
	else						//Checks to see if heading is between 270 - 360 degrees
	{
		bearing = (360.0 - heading);
		cout << "North " << bearing << " degrees West." << endl;	//Output compass bearing
	}
	
    return 0;
}
  #2  
Old 24-Feb-2006, 17:05
Chris.Dev's Avatar
Chris.Dev Chris.Dev is offline
Junior Member
 
Join Date: Jan 2005
Posts: 48
Chris.Dev will become famous soon enough

Re: Compile errors


Quote:
Originally Posted by earachefl
CPP / C++ / C Code:



eise if (heading < 180.0)	//Checks to see if heading is between 90 - <180 degrees







Everything compiles fine for me with all warnings turned on except for that line... The problem being that that is an 'eise' instead of an 'else'.

Other than that it should compile.
  #3  
Old 24-Feb-2006, 17:12
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Re: Compile errors


D'oh!!!!!!

guess I have to get a bigger display.... or better glasses.

I'm working in XCode 2 - and can't get the font size bigger for some reason. Format>Font>Bigger (or >Smaller, for that matter) doesn't do anything. Are you not supposed to be able to change font size in the main.cpp window?
  #4  
Old 24-Feb-2006, 17:49
earachefl earachefl is offline
Member
 
Join Date: Feb 2006
Posts: 178
earachefl is on a distinguished road

Re: Compile errors


if anyone cares, I caught the errors in my code and revised as follows:
CPP / C++ / C Code:
#include <iostream>
using namespace std;

int main () 
{
	float heading;	//Input - compass heading
	float bearing;
	
	cout << "Enter compass heading:";
	cin >> heading;
	
	if ((heading < 0.0) || (heading > 360.0))	//Checks to see if heading entry is in valid range
	{
		cout << "Invalid compass heading!" << endl;	//Output error message
	}
	
	else if (heading < 90.0)	//Checks to see if heading is between 0 -  <90 degrees
	{
		bearing = heading;
		cout << "North " << bearing << " degrees East." << endl;	//Output compass bearing
	}
		
	else if (heading < 180.0)	//Checks to see if heading is between 90 - <180 degrees
	{
		bearing = (180.0 - heading);
		cout << "South " << bearing << " degrees East." << endl;	//Output compass bearing
	}
		
	else if (heading < 270.0)	//Checks to see if heading is between 180 - <270 degrees
	{
		bearing = (heading - 180);
		cout << "South " << bearing << " degrees West." << endl;	//Output compass bearing
	}
		
	else						//Checks to see if heading is between 270 - 360 degrees
	{
		bearing = (360.0 - heading);
		cout << "North " << bearing << " degrees West." << endl;	//Output compass bearing
	}
	
    return 0;
}
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler errors vital_101 C Programming Language 4 12-Jan-2006 14:53
In Need of Some Serious Help...compiling errors [C++] needcishelp C++ Forum 25 21-Dec-2005 02:26
conditional compile logic cable_guy_67 C++ Forum 15 03-Dec-2005 19:44
Help with compiler errors Krandygrl00 C++ Forum 3 01-Jun-2005 08:45
Linker errors with multiple file progam nkhambal C Programming Language 2 24-Apr-2005 03:37

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 12:06.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.