Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jan 31st, 2008, 11:19 AM   #1
gmann145
Newbie
 
Join Date: Jan 2008
Posts: 7
Rep Power: 0 gmann145 is on a distinguished road
Exclamation some help

hey im writting a simple code for a school assignment and for the life of me i cant figure out whats wrong with it, here it is
c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8. int choice;
  9. double a,r,l,w;
  10. const double z = 3.14159;
  11. const double k = .5;
  12.  
  13. cout<<"Which would you like to do?/n";
  14. cout<<"Enter 1 for area of a circle/n";
  15. cout<<"Enter 2 for area of a rectangle/n";
  16. cout<<"Enter 3 for area of a Triangle/n";
  17. cout<<"Enter 4 if you are a nancy/n";
  18. cin >> choice;
  19.  
  20. if(choice>=1 && choice<=3)
  21. {
  22.  
  23. switch(choice)
  24. {
  25. case 1: cout<<"What is the radius?/n";
  26. cin << r;
  27. a=z*(r*r);
  28. cout<<"The area equals " <<a;
  29. break;
  30. case 2: cout<<"What are the width and legnth of the rectangle?/n";
  31. cin>> w >> l;
  32. a=l*w;
  33. cout <<"The area equals " <<a;
  34. break;
  35. case 3: cout<<"What are the base and height of the triagnle?/n";
  36. cin>> l >> w;
  37. a=l*w*k;
  38. cout<<"The area euqals "<<a;
  39.  
  40. case 4: break;
  41. }
  42. }
  43.  
  44. else if (x!=4)
  45. {
  46. cout<<"That's not a choice, re-run the program";
  47. }
  48.  
  49.  
  50.  
  51. system("pause");
  52. return 0;
  53. }

if anyone could help me it would be much appreciated

Last edited by Ancient Dragon; Jan 31st, 2008 at 6:50 PM. Reason: add code tags
gmann145 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:06 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC