Thread: Help me! C++
View Single Post
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Help me! C++

 
0
  #3
Sep 15th, 2007
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int mDays;
  9. int maxhours;
  10. char pkg = 'Z';
  11. cout << "Enter pkg A, B or C: ";
  12. cin >> pkg;
  13. if ( pkg == 'A' || pkg == 'a' || pkg == 'b'
  14. || pkg == 'B' || pkg == 'C' || pkg == 'c' )
  15. {
  16. int month;
  17. cout << "Enter Month 1 through 12: ";
  18. cin >> month;
  19. if ( month >= 1 && month <= 12 )
  20. {
  21. int hrs;
  22. cout << "Enter hrs: ";
  23. cin >> hrs;
  24. if ( month == 1 || month == 3 || month == 5
  25. || month == 7 || month == 8 || month == 10 || month == 12 )
  26. {
  27. mDays = 31;
  28. maxhours = 744;
  29. }
  30. else if ( month == 4 || month == 6 || month == 9 || month == 11 )
  31. {
  32. mDays = 30;
  33. maxhours = 720;
  34. }
  35. else if ( month == 2 )
  36. {
  37. mDays = 28;
  38. maxhours = 672;
  39. }
  40. else
  41. {
  42. mDays = 29;
  43. maxhours = 696;
  44. }
  45. int yr;
  46. cout << "Enter Year 1990 - 2020" << endl;
  47. cin >> yr;
  48. if ( yr >= 1990 && month <= 2020 )
  49. {
  50. if ( ( yr % 4 ) != 0 ) //leap year
  51. {
  52. }
  53. }
  54. else
  55. {
  56. cout << " Year " << yr << " invalid " << endl;
  57. }
  58. }
  59. else
  60. {
  61. cout << "Month " << month << " invalid" << endl;
  62. }
  63. }
  64. else
  65. {
  66. cout << "Inalid pkg value" << endl;
  67. }
  68. }

Your if else statements look rather odd at first glance? Maybe?
Reply With Quote