Advertisement
melybdenum

assignmentMel

Mar 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void main()
  5. {
  6.     int a, planType, postpaid, prepaid, minCall, msgSent;
  7.     float billRate, callRate = 0.06 , smsRate = 0.01, totalBill ;
  8.     char custName[100], phoneNum[20];
  9.  
  10.     printf("Enter your name: ");
  11.     gets(custName);
  12.     printf("\nEnter your phone number: ");
  13.     scanf(" %s", &phoneNum);
  14.     printf("\nWhich phone plan do you want to choose? (1 - postpaid, 2 - prepaid) ");
  15.     scanf(" %d", &planType);
  16.  
  17.  
  18.     if (planType == 1) {
  19.  
  20.    /* for loop execution */
  21.         for( a = 1; a <= 1; a = a + 1 ){
  22.         printf("How many bills do you want to pay? ");
  23.         scanf(" %d", &a);
  24.         }
  25.  
  26.         printf("\nWhich postpaid plan do you want? (98, 128, 158, 188) ");
  27.         scanf(" %d", &postpaid);
  28.     }
  29.         if (postpaid == 98) {
  30.             printf("\nSubscribed to MaxisONE Plan 98!\nPlan includes 15GB All Day Data, 15GB Weekend Data and unlimited calls & SMS");
  31.             billRate = 98.00;
  32.         }
  33.         else if (postpaid == 128) {
  34.             printf("\nSubscribed to MaxisONE Plan 128!\nPlan includes 40GB All Day Data and unlimited calls & SMS");
  35.             billRate = 128.00;
  36.         }
  37.         else if (postpaid == 158) {
  38.             printf("\nSubscribed to MaxisONE Plan 158!\nPlan includes 50GB All Day Data and unlimited calls & SMS");
  39.             billRate = 158.00;
  40.         }
  41.         else if (postpaid == 188) {
  42.             printf("\nSubscribed to MaxisONE Plan 188!\nPlan includes 60 GB All Day Data and unlimited calls & SMS");
  43.             billRate = 188.00;
  44.         }
  45.      else {
  46.         printf("\nWhich prepaid plan do you want? (35, 45, 60, 70) ");
  47.         scanf(" %d", &prepaid);
  48.         switch(prepaid) {
  49.         case 35 :
  50.             printf("\nSubscribed to Hotlink RED Plan 35!\n30-day validity Plan which includes 6GB All Day Data, free Non-Stop RED Chat or free Non-Stop RED Social");
  51.             billRate = 35.00;
  52.             break;
  53.         case 45 :
  54.             printf("\nSubscribed to Hotlink RED Plan 45!\n30-day validity Plan which includes 8GB All Day Data, free Non-Stop RED Chat or free Non-Stop RED Social");
  55.             billRate = 45.00;
  56.             break;
  57.         case 60 :
  58.             printf("\nSubscribed to Hotlink RED Plan 60!\n30-day validity Plan which includes 6GB All Day Data, unlimited calls & SMS, free Non-Stop RED Chat or free Non-Stop RED Social");
  59.             billRate = 60.00;
  60.             break;
  61.         case 70 :
  62.             printf("\nSubscribed to Hotlink RED Plan 70!\n30-day validity Plan which includes 8GB All Day Data, unlimited calls & SMS, free Non-Stop RED Chat or free Non-Stop RED Social");
  63.             billRate = 70.00;
  64.         }
  65.     }
  66.  
  67.     printf("\n ");
  68.     printf("\n===================================================\n");
  69.     printf("\t\tMAXIS eBILL");
  70.     printf("\n===================================================\n");
  71.     printf("Name: ");
  72.     puts(custName);
  73.     printf("Phone Number: %s", phoneNum);
  74.     printf("\nPlan Type: %d", planType);
  75.  
  76.     if (planType == 1) {
  77.         printf("\nPostpaid Plan: %d", postpaid);
  78.         printf("\nTotal Bill: RM %.2f", billRate);
  79.         printf("\n====================================================\n");
  80.     }
  81.     else {
  82.         printf("\nPrepaid Plan: %d", prepaid);
  83.         printf("\nHow many messages sent this month? ");
  84.         scanf(" %d", &msgSent);
  85.         printf("How long are your calls this month? (minutes) ");
  86.         scanf(" %d", &minCall);
  87.         totalBill = (callRate*2*minCall) + (smsRate*msgSent) + billRate;
  88.         printf("Total Bill: %.2f", totalBill);
  89.         printf("\n===================================================\n");
  90.  
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement