currency conversion program error

Reply

Join Date: Oct 2006
Posts: 10
Reputation: sunny123 is an unknown quantity at this point 
Solved Threads: 0
sunny123 sunny123 is offline Offline
Newbie Poster

currency conversion program error

 
0
  #1
Nov 29th, 2006
ive created this currency conversion program
which converts the currency then adds commission, but its got a error saying undefined symbol true in function main
can someone help me ive only got the one error with it.


  1. #include <iostream.h>
  2.  
  3. int choice;
  4. double pounds;
  5. double USdollar;
  6. double Euro;
  7. double interest;
  8.  
  9. int main(){
  10. cout << "Select what you want to convert." <<endl;
  11. cout << "1.Pounds to US dollar." <<endl;
  12. cout << "2.Pounds to Euro." << endl;
  13. cin >> choice;
  14.  
  15. while (true){
  16.  
  17. //converts pounds to US dollars
  18. if (choice == 1){
  19. cout << "Please enter amount you want to convert." <<endl;
  20. cin >> pounds;
  21. USdollar = pounds * 0.5; //change the conversion rate
  22. cout << USdollar<< endl;
  23. if (pounds <= 1000){
  24. cout << "Interest rate is 1% of this amount." <<endl;
  25. interest = USdollar + (USdollar * 0.01);
  26. cout << interest << endl;
  27. }
  28. if (pounds > 1000){
  29. cout << "Interest rate is 3% of this amount." <<endl;
  30. interest = USdollar + (USdollar * 0.03);
  31. cout << interest << endl;
  32. }break;
  33. }
  34. //converts pounds to euro
  35. if (choice == 2){
  36. cout << "Please enter amount you want to convert." <<endl;
  37. cin >> pounds;
  38. Euro = pounds * 0.3; //change the conversion rate
  39. cout << Euro<< endl;
  40. if (pounds <= 1000){
  41. cout << "Interest rate is 1% of this amount." <<endl;
  42. interest = Euro + (Euro * 0.01);
  43. cout << interest << endl;
  44. }
  45. if (pounds > 1000){
  46. cout << "Interest rate is 3% of this amount." <<endl;
  47. interest = Euro + (Euro * 0.03);
  48. cout << interest << endl;
  49. }break;
  50. }
  51. if (choice != 1 && choice !=2){
  52. cout <<"Invalid choice. Enter again."<<endl;
  53. }
  54. }return 0;
  55. }
Last edited by sunny123; Nov 29th, 2006 at 12:11 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: currency conversion program error

 
0
  #2
Nov 29th, 2006
true has not been defined. Define it.
Last edited by WaltP; Nov 29th, 2006 at 12:42 pm.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 57
Reputation: may4life is an unknown quantity at this point 
Solved Threads: 2
may4life may4life is offline Offline
Junior Poster in Training

Re: currency conversion program error

 
0
  #3
Nov 29th, 2006
It works fine on my compiler :-S
Try declaring a boolean variable and have that in the while loop
  1. bool keepLooping = true;
  2.  
  3. ...
  4.  
  5. while (keepLooping)
  6. {
  7. ...
  8. }

Or simply use the forever loop
  1. for (;;)
  2. {
  3. ...
  4. }
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 10
Reputation: sunny123 is an unknown quantity at this point 
Solved Threads: 0
sunny123 sunny123 is offline Offline
Newbie Poster

Re: currency conversion program error

 
0
  #4
Nov 29th, 2006
thankyou
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,050
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 331
Moderator
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: currency conversion program error

 
0
  #5
Nov 29th, 2006
Originally Posted by sunny123
  1. #include <iostream.h>
iostream.h is outdated - use iostream instead:
http://www.devx.com/tips/Tip/14447
(you also either need to put using namespace std; after the inclusion of iostream, or place std:: in front of each Standard Template Library object)

My suspection of "undefined symbol true" is that the compiler is in 'C' mode or something... perhaps in the configuration or something you can change it. In any case, it works fine on mine (gcc).

Originally Posted by may4life
Try declaring a boolean variable and have that in the while loop
Code:
  1. bool keepLooping = true;
  2.  
  3. ...
  4.  
  5. while (keepLooping)
  6. {
  7. ... }
What an awful way of doing it. Firstly, if the compiler doesn't recognize true in the while loop, what makes you think it will recognize it in a variable assignment? Secondly, it's much shorter to simply create a while loop with '1' like the following:
  1. while(1) {
  2. ...
  3. }
That should work for ya.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC