I have just finished more than half of my assignment for school. But i am completely stumped on the second problem.
But now i need to prompt the user for the state string.
So far i have this:
When you compile and enter the inputs it looks like this.Code:#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 2
#define PERSN_SZE 9
typedef struct {
char firstName[30];
char lastName[30];
char street[35];
char city[20];
char state[3];
int zip;
char phone[15];
int accountId;
} Customer;
int main()
{
Customer customer[SIZE];
int i;
for ( i = 0; i < 9; i++)
{
customer[i].accountId = i + 1;
printf("\nEnter Data for Customer %d", i + 1);
printf("\nEnter First Last Phone: ");
scanf("%s %s %s", customer[i].firstName, customer[i].lastName, customer[i].phone);
printf("\nEnter Address (Street City State ZIP): ");
scanf("%s %s %s %d", customer[i].street, customer[i].city, customer[i].state, &customer[i].zip);
}
for ( i = 0; i < 9; i++)
{
printf("=============================================================\n");
printf("\nData for Customer %d\n", customer[i].accountId);
printf("Account: %d\n", customer[i].accountId);
printf("Name: %s %s\n", customer[i].firstName, customer[i].lastName);
printf("Addr: %s %s %s %d\n", customer[i].street, customer[i].city, customer[i].state, customer[i].zip);
printf("Phone: %s\n", customer[i].phone);
}
system("pause");
}
Enter Data for Customer 0
Enter First Last Phone: Doug Oregon 123-456-7890
Enter Address (Street City State ZIP): Main Portland OR 12345
Enter Data for Customer 1
Enter First Last Phone: Doug Washington 123-456-7890
Enter Address (Street City State ZIP): Main Portland WA 12345
Enter Data for Customer 2
Enter First Last Phone: Doug California 123-456-7890
Enter Address (Street City State ZIP): Main Portland CA 12345
Enter Data for Customer 3
Enter First Last Phone: Doug Nevada 123-456-7890
Enter Address (Street City State ZIP): Main Portland NV 12345
Enter Data for Customer 4
Enter First Last Phone: Doug Colorado 123-456-7890
Enter Address (Street City State ZIP): Main Portland CO 12345
Enter Data for Customer 5
Enter First Last Phone: Another Colorado 123-456-7890
Enter Address (Street City State ZIP): Main Portland CO 12345
Enter Data for Customer 6
Enter First Last Phone: Doug Arizona 123-456-7890
Enter Address (Street City State ZIP): Main Portland AZ 12345
Enter Data for Customer 7
Enter First Last Phone: Doug Florida 123-456-7890
Enter Address (Street City State ZIP): Main Portland FL 12345
Enter Data for Customer 8
Enter First Last Phone: Doug Georgia 123-456-7890
Enter Address (Street City State ZIP): Main Portland GA 12345
Enter Data for Customer 9
Enter First Last Phone: Doug Jones 123-456-7890
Enter Address (Street City State ZIP): Main Portland CO 12345
But now i need to prompt the user for the state string. Which should give me output like this:
Enter 2-character state code: CO
Data for Customer 4
Account: 4
Name: Doug Colorado
Addr: Main Portland CO 12345
Phone: 123-456-7890
Data for Customer 5
Account: 5
Name: Another Colorado
Addr: Main Portland CO 12345
Phone: 123-456-7890
Data for Customer 9
Account: 9
Name: Doug Jones
Addr: Main Portland CO 12345
Phone: 123-456-7890