snaptrap013 icon

Untitled

snaptrap013 | PRO | 03/11/21 03:22:58 AM UTC | 0 ⭐ | 877 👁️ | Never ⏰ | []
C |

1.33 KB

|

None

|

0 👍

/

0 👎

#include <stdio.h>
 
int main()
{
    char name[20],state[10],delivery_option;
    float parcel_weight,total_payment;
    
    printf("Enter your name: ");
    gets(name);
    
    printf("Enter your state: ");
    gets(state);
    
    printf("Enter your delivery option: ");
    scanf("%c",&delivery_option);
    
    printf("Please enter your parcel weight(kg): ");
    scanf("%f",&parcel_weight);
    
    if(parcel_weight<2.5)
    {
       if(delivery_option == 'D')
          total_payment=parcel_weight*3.50;
       else 
          total_payment=parcel_weight*4.50;
    }
    else if(parcel_weight >= 2.5 && parcel_weight <= 5)
    {
       if(delivery_option == 'D' )
          total_payment=parcel_weight*2.85;
       else
          total_payment=parcel_weight*3.85;
    }
    else if(parcel_weight > 5)
    {
        if(delivery_option == 'D')
           total_payment=parcel_weight*2.45;
        else
           total_payment=parcel_weight*3.45;
    }
    printf("\n\nNama               : %s",name);
    printf("\nState                : %s",state);
    printf("\nParcel Weight        : %.2f", parcel_weight);
    printf("\nDelivery Option (D/P): %c", delivery_option);
    printf("\n--------------------------------------");
    printf("\nTotal Payment        : %.2f",total_payment);
 
    return 0;
}

Comments