Advertisement
snaptrap013

Untitled

Mar 10th, 2021
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     char name[20],state[10],delivery_option;
  6.     float parcel_weight,total_payment;
  7.    
  8.     printf("Enter your name: ");
  9.     gets(name);
  10.    
  11.     printf("Enter your state: ");
  12.     gets(state);
  13.    
  14.     printf("Enter your delivery option: ");
  15.     scanf("%c",&delivery_option);
  16.    
  17.     printf("Please enter your parcel weight(kg): ");
  18.     scanf("%f",&parcel_weight);
  19.    
  20.     if(parcel_weight<2.5)
  21.     {
  22.        if(delivery_option == 'D')
  23.           total_payment=parcel_weight*3.50;
  24.        else
  25.           total_payment=parcel_weight*4.50;
  26.     }
  27.     else if(parcel_weight >= 2.5 && parcel_weight <= 5)
  28.     {
  29.        if(delivery_option == 'D' )
  30.           total_payment=parcel_weight*2.85;
  31.        else
  32.           total_payment=parcel_weight*3.85;
  33.     }
  34.     else if(parcel_weight > 5)
  35.     {
  36.         if(delivery_option == 'D')
  37.            total_payment=parcel_weight*2.45;
  38.         else
  39.            total_payment=parcel_weight*3.45;
  40.     }
  41.     printf("\n\nNama               : %s",name);
  42.     printf("\nState                : %s",state);
  43.     printf("\nParcel Weight        : %.2f", parcel_weight);
  44.     printf("\nDelivery Option (D/P): %c", delivery_option);
  45.     printf("\n--------------------------------------");
  46.     printf("\nTotal Payment        : %.2f",total_payment);
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement