Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- struct addr {
- char street[30];
- char city[30];
- char state[20];
- };
- struct date {
- int month;
- int day;
- int year;
- };
- struct policy {
- int polnumber;
- char name[30];
- struct addr address;
- int kind;
- union {
- struct {
- char beneficiary[30];
- struct date birthday;
- } life;
- struct {
- char license[10];
- char model[15];
- } autoh;
- struct {
- int yearbuilt;
- } home;
- } policyinfo;
- };
- int main() {
- char ans;
- struct policy pol;
- printf("\n*** Welcome to Infodiliman Insurance System! ***\n");
- printf("\nEnter name: "); scanf("%s%c", pol.name);
- printf("Enter address street: "); scanf("%s%c", pol.address.street);
- printf("Enter address city: "); scanf("%s%c", pol.address.city);
- printf("Enter address state: "); scanf("%s%c", pol.address.state);
- printf("Enter policy number: "); scanf("%d%c", &pol.polnumber);
- printf("\n\n1 for Life Insurance\n");
- printf("2 for Auto Insurance\n");
- printf("3 for Home Insurance\n\n");
- p1:
- printf("\nEnter Insurance System No.(1-3): "); scanf("%d%c", &pol.kind);
- switch(pol.kind) {
- case 1:
- printf("\n** Welcome To Our Life Insurance! **\n\n");
- printf("Enter beneficiary: ");
- scanf("%s%c", pol.policyinfo.life.beneficiary);
- printf("Enter date (MM/DD/YYYY): ");
- scanf("%d/%d/%d%c", &pol.policyinfo.life.birthday.month, &pol.policyinfo.life.birthday.day, &pol.policyinfo.life.birthday.year);
- break;
- case 2:
- printf("\n** Welcome To Our Auto Insurance! **\n\n");
- printf("Enter license number: ");
- scanf("%s%c", pol.policyinfo.autoh.license);
- printf("Enter car model: ");
- scanf("%s%c", pol.policyinfo.autoh.model);
- break;
- case 3:
- printf("\n** Welcome To Our Home Insurance! **\n\n");
- printf("Enter year built: ");
- scanf("%d%c", &pol.policyinfo.home.yearbuilt);
- break;
- }
- printf("\n\n**************************\n");
- printf("Name: %s\n"
- "Address: %s %s %s\n"
- "Policy Number: %d\n"
- "Insurance System No.: %d\n",
- pol.name,
- pol.address.street,
- pol.address.city,
- pol.address.state,
- pol.polnumber,
- pol.kind);
- switch(pol.kind) {
- case 1:
- printf("Beneficiary: %s\n", pol.policyinfo.life.beneficiary);
- printf("Birth Date: %d/%d/%d\n", pol.policyinfo.life.birthday.month, pol.policyinfo.life.birthday.day, pol.policyinfo.life.birthday.year);
- break;
- case 2:
- printf("License Number: %s\n", pol.policyinfo.autoh.license);
- printf("Car Model: %s\n", pol.policyinfo.autoh.model);
- break;
- case 3:
- printf("Year Built: %d\n", pol.policyinfo.home.yearbuilt);
- break;
- }
- printf("**************************\n");
- printf("\nDo you want to avail another Insurance?[y/n]: ");
- scanf("%s",&ans);
- if(ans=='y' || ans=='Y'){
- goto p1;}
- else{
- printf("Thank You Come Again!");
- }
- getch();
- }
Add Comment
Please, Sign In to add comment