Thread: Help me! C++
View Single Post
Join Date: Sep 2007
Posts: 1
Reputation: leolima is an unknown quantity at this point 
Solved Threads: 0
leolima leolima is offline Offline
Newbie Poster

Help me! C++

 
0
  #1
Sep 15th, 2007
Hey guys!

CAn u tell me if my program is right?

First, I need to get a Pkg and validate;
Second,get month and validate;
Third, determinate max hours;
*If FEB;
Fourth, get year and validate(1990-2020)
check for leap yr.
Fifth, get hours and validate against maxhours;
and calculate the bill ^^(month)

I have 3 pkg
PKG A = $12 month
PKG B = $18 " " "
PKG C = $25 " " "

Thank you!!

Thx
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void main()
  6. {
  7. int mDays;
  8. int maxhours;
  9.  
  10. char pkg = 'Z';
  11. cout<<"Enter pkg A, B or C: ";
  12. cin >> pkg;
  13.  
  14. if( pkg == 'A'||pkg =='a' ||pkg =='b' ||pkg == 'B'|| pkg == 'C'||pkg =='c' )
  15. {
  16. int month;
  17. cout<<"Enter Month 1 through 12: ";
  18. cin>>month;
  19.  
  20. if(month>=1 && month<=12)
  21. {
  22. int hrs;
  23. cout<<"Enter hrs: ";
  24. cin>>hrs;
  25. if (month==1||month==3||month==5||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. }
  36. else if(month ==2)
  37. {
  38. mDays = 28;
  39. maxhours = 672;
  40. }
  41. else
  42. {
  43. mDays = 29;
  44. maxhours = 696;
  45. }
  46.  
  47. int yr;
  48. cout<<"Enter Year 1990 - 2020"<<endl;
  49. cin>>yr;
  50.  
  51. if(yr>=1990 && month<=2020)
  52. {
  53. if((yr%4)!=0) //leap year
  54. {
  55.  
  56. }
  57.  
  58.  
  59.  
  60. }
  61. else
  62. {
  63. cout<<" Year " << yr << " invalid "<<endl;
  64. }
  65.  
  66.  
  67.  
  68. }
  69.  
  70. else
  71. {
  72. cout<<"Month " << month << " invalid"<<endl;
  73. }
  74.  
  75.  
  76.  
  77. }
  78.  
  79. else
  80. {
  81. cout<<"Inalid pkg value"<<endl;
  82. }
  83. }//end main
Last edited by Ancient Dragon; Sep 15th, 2007 at 6:28 pm. Reason: add code tags
Reply With Quote