Guest User

Untitled

a guest
Jan 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <conio.h>
  4.  
  5.  
  6.  
  7. struct addr {
  8.  
  9. char street[30];
  10.  
  11. char city[30];
  12.  
  13. char state[20];
  14.  
  15. };
  16.  
  17.  
  18.  
  19. struct date {
  20.  
  21. int month;
  22.  
  23. int day;
  24.  
  25. int year;
  26.  
  27. };
  28.  
  29.  
  30.  
  31. struct policy {
  32.  
  33. int polnumber;
  34.  
  35. char name[30];
  36.  
  37. struct addr address;
  38.  
  39. int kind;
  40.  
  41.  
  42.  
  43. union {
  44.  
  45. struct {
  46.  
  47. char beneficiary[30];
  48.  
  49. struct date birthday;
  50.  
  51. } life;
  52.  
  53. struct {
  54.  
  55. char license[10];
  56.  
  57. char model[15];
  58.  
  59. } autoh;
  60.  
  61. struct {
  62.  
  63. int yearbuilt;
  64.  
  65. } home;
  66.  
  67. } policyinfo;
  68.  
  69. };
  70.  
  71.  
  72.  
  73. int main() {
  74.  
  75.  
  76.  
  77. char ans;
  78.  
  79. struct policy pol;
  80.  
  81.  
  82.  
  83. printf("\n*** Welcome to Infodiliman Insurance System! ***\n");
  84.  
  85.  
  86. printf("\nEnter name: "); scanf("%s%c", pol.name);
  87.  
  88. printf("Enter address street: "); scanf("%s%c", pol.address.street);
  89.  
  90. printf("Enter address city: "); scanf("%s%c", pol.address.city);
  91.  
  92. printf("Enter address state: "); scanf("%s%c", pol.address.state);
  93.  
  94. printf("Enter policy number: "); scanf("%d%c", &pol.polnumber);
  95.  
  96. printf("\n\n1 for Life Insurance\n");
  97.  
  98. printf("2 for Auto Insurance\n");
  99.  
  100. printf("3 for Home Insurance\n\n");
  101.  
  102. p1:
  103.  
  104. printf("\nEnter Insurance System No.(1-3): "); scanf("%d%c", &pol.kind);
  105.  
  106.  
  107.  
  108. switch(pol.kind) {
  109.  
  110. case 1:
  111.  
  112. printf("\n** Welcome To Our Life Insurance! **\n\n");
  113.  
  114. printf("Enter beneficiary: ");
  115.  
  116. scanf("%s%c", pol.policyinfo.life.beneficiary);
  117.  
  118. printf("Enter date (MM/DD/YYYY): ");
  119.  
  120. scanf("%d/%d/%d%c", &pol.policyinfo.life.birthday.month, &pol.policyinfo.life.birthday.day, &pol.policyinfo.life.birthday.year);
  121.  
  122. break;
  123.  
  124. case 2:
  125.  
  126. printf("\n** Welcome To Our Auto Insurance! **\n\n");
  127.  
  128. printf("Enter license number: ");
  129.  
  130. scanf("%s%c", pol.policyinfo.autoh.license);
  131.  
  132. printf("Enter car model: ");
  133.  
  134. scanf("%s%c", pol.policyinfo.autoh.model);
  135.  
  136. break;
  137.  
  138. case 3:
  139.  
  140. printf("\n** Welcome To Our Home Insurance! **\n\n");
  141.  
  142. printf("Enter year built: ");
  143.  
  144. scanf("%d%c", &pol.policyinfo.home.yearbuilt);
  145.  
  146. break;
  147.  
  148. }
  149.  
  150.  
  151. printf("\n\n**************************\n");
  152.  
  153. printf("Name: %s\n"
  154.  
  155. "Address: %s %s %s\n"
  156.  
  157. "Policy Number: %d\n"
  158.  
  159. "Insurance System No.: %d\n",
  160.  
  161. pol.name,
  162.  
  163. pol.address.street,
  164.  
  165. pol.address.city,
  166.  
  167. pol.address.state,
  168.  
  169. pol.polnumber,
  170.  
  171. pol.kind);
  172.  
  173.  
  174.  
  175. switch(pol.kind) {
  176.  
  177. case 1:
  178.  
  179. printf("Beneficiary: %s\n", pol.policyinfo.life.beneficiary);
  180.  
  181. printf("Birth Date: %d/%d/%d\n", pol.policyinfo.life.birthday.month, pol.policyinfo.life.birthday.day, pol.policyinfo.life.birthday.year);
  182.  
  183. break;
  184.  
  185. case 2:
  186.  
  187. printf("License Number: %s\n", pol.policyinfo.autoh.license);
  188.  
  189. printf("Car Model: %s\n", pol.policyinfo.autoh.model);
  190.  
  191. break;
  192.  
  193. case 3:
  194.  
  195. printf("Year Built: %d\n", pol.policyinfo.home.yearbuilt);
  196.  
  197. break;
  198.  
  199. }
  200.  
  201. printf("**************************\n");
  202.  
  203.  
  204. printf("\nDo you want to avail another Insurance?[y/n]: ");
  205.  
  206. scanf("%s",&ans);
  207.  
  208. if(ans=='y' || ans=='Y'){
  209.  
  210. goto p1;}
  211.  
  212. else{
  213.  
  214. printf("Thank You Come Again!");
  215.  
  216. }
  217.  
  218.  
  219. getch();
  220.  
  221. }
Add Comment
Please, Sign In to add comment