print currentprice, upcomingprice and the difference

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • m konstantakis
    New Member
    • Oct 2010
    • 1

    #1

    print currentprice, upcomingprice and the difference

    Code:
    #include <stdio.h>
    int main(void)
    {
    int currentprice,upcomingprice;
    int currentprice1,currentprice2,currentprice3;
    int upcomingprice1,upcomingprice2,upcomingprice3;
    int difference;
    float gallons;
    printf( "Enter the water consumption \n ", gallons );
    	scanf( "%f", &gallons);
    
    switch(currentprice){
          case 1:
          currentprice1=gallons*7;
          break;
          case 2:
          currentprice2=gallons*9;
          break;
          case 3:
          currentprice3=gallons*11;
          break;
    }
    switch(upcomingprice) {
          case 4:
          upcomingprice1=gallons*6;
          break;
          case 5:
          upcomingprice2=gallons*9;
          break;
          case 6:
          upcomingprice3=gallons*13;
          break;
    
    
      }
    
    while (0<=gallons<=100000) {
    		currentprice1=gallons*7;
    			break;
    }
    while (100000<gallons<=150000) {
    		currentprice2=gallons*9;
    			break;
    }
    while (150000<gallons>=500000) {
    		currentprice3=gallons*11;
    			break;
    }
    while (gallons <= 50000) {
    		upcomingprice1=gallons*6;
    		    break;
    }
    while (50000<gallons&&gallons<=125000) {
    		upcomingprice2=gallons*9;
    
    			break;
    }
    while (125000<gallons,gallons=500000) {
    		upcomingprice3=gallons*11;
    			break;
    return 0;
    }
    {
    		currentprice=currentprice1 || currentprice2 || currentprice3;
    		upcomingprice=upcomingprice1 || upcomingprice2 || upcomingprice3;
    		difference=upcomingprice-currentprice;
    		printf("customer water consumption during the current policy is %d", currentprice);
    		printf("customer water consumption for the upcoming policy is %d", upcomingprice);
    		printf("the difference between upcoming and current cost is %d", difference);
    
    }
    }
    that is the program i have wroten i want to print currentprice,up comingprice and the difference.if anyone can help.thanks on behalf.
    Last edited by MMcCarthy; Oct 24 '10, 08:34 AM. Reason: added code tags
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    What do you intend to accomplish with lines 64 and 65? The result of the || operator is either 0 or 1.

    Comment

    Working...