By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

print currentprice, upcomingprice and the difference

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. int main(void)
  3. {
  4. int currentprice,upcomingprice;
  5. int currentprice1,currentprice2,currentprice3;
  6. int upcomingprice1,upcomingprice2,upcomingprice3;
  7. int difference;
  8. float gallons;
  9. printf( "Enter the water consumption \n ", gallons );
  10.     scanf( "%f", &gallons);
  11.  
  12. switch(currentprice){
  13.       case 1:
  14.       currentprice1=gallons*7;
  15.       break;
  16.       case 2:
  17.       currentprice2=gallons*9;
  18.       break;
  19.       case 3:
  20.       currentprice3=gallons*11;
  21.       break;
  22. }
  23. switch(upcomingprice) {
  24.       case 4:
  25.       upcomingprice1=gallons*6;
  26.       break;
  27.       case 5:
  28.       upcomingprice2=gallons*9;
  29.       break;
  30.       case 6:
  31.       upcomingprice3=gallons*13;
  32.       break;
  33.  
  34.  
  35.   }
  36.  
  37. while (0<=gallons<=100000) {
  38.         currentprice1=gallons*7;
  39.             break;
  40. }
  41. while (100000<gallons<=150000) {
  42.         currentprice2=gallons*9;
  43.             break;
  44. }
  45. while (150000<gallons>=500000) {
  46.         currentprice3=gallons*11;
  47.             break;
  48. }
  49. while (gallons <= 50000) {
  50.         upcomingprice1=gallons*6;
  51.             break;
  52. }
  53. while (50000<gallons&&gallons<=125000) {
  54.         upcomingprice2=gallons*9;
  55.  
  56.             break;
  57. }
  58. while (125000<gallons,gallons=500000) {
  59.         upcomingprice3=gallons*11;
  60.             break;
  61. return 0;
  62. }
  63. {
  64.         currentprice=currentprice1 || currentprice2 || currentprice3;
  65.         upcomingprice=upcomingprice1 || upcomingprice2 || upcomingprice3;
  66.         difference=upcomingprice-currentprice;
  67.         printf("customer water consumption during the current policy is %d", currentprice);
  68.         printf("customer water consumption for the upcoming policy is %d", upcomingprice);
  69.         printf("the difference between upcoming and current cost is %d", difference);
  70.  
  71. }
  72. }
  73.  
that is the program i have wroten i want to print currentprice,upcomingprice and the difference.if anyone can help.thanks on behalf.
Oct 24 '10 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 2,396
What do you intend to accomplish with lines 64 and 65? The result of the || operator is either 0 or 1.
Oct 24 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.