Need help for my project. Everytime I run the file when it comes to the part of displaying all the user input, only the ordered item,quantity,and total amount of purchased was being displayed.The rest such as the name,address,postal code,contact number,email add,mode of payment and claim item through appears <null>..What's wrong with this...I need an answer badly please help..
Code:
#include<stdio.h>
main()
{
int item_code, quantity;
double tprice;
char ans, y;
//Display Welcome
printf("\n\t*****************************************************************\n\t*\t\t\t\t\t\t\t\t*\n\t*");
printf("\t ::::: WELCOME TO PILLOW <^.^> HOUSE :::::\t\t*\n\t*\t\t\t\t\t\t\t\t*\n\t*");
printf("****************************************************************\n\n");
printf("\n\n\tPillow <^.^> House offers varieties of pillows that you can use\n\teverywhere.");
printf("You can use them with full comfort because our items\n\tare made of 100 percent fiber and the fabric used");
printf(" is pure cotton.");
printf("\n\nPlease select your order in the list of items below: ");
printf("\n\nPrice \t\tItem Code \t\tName of Item");
printf("\n\n349.00 \t\t 1 \t\t\tDream Pillow");
printf("\n\n349.00 \t\t 2 \t\t\tBolster Pillow");
printf("\n\n549.00 \t\t 3 \t\t\tFantasy Pillow");
printf("\n\n599.00 \t\t 4 \t\t\tHealth Pillow");
//Enter item Code
printf("\n\n\nEnter the item code: ");
scanf("%d", &item_code);
if ((item_code>0)&&(item_code<5)){
printf("\nEnter Item Quantity: ");
scanf("%d", &quantity);
switch(item_code){
case 1:
printf("\nOrdered Item: DREAM PILLOW");
tprice = 349.00 * quantity;
break;
case 2:
printf("\nOrdered Item: BOLSTER PILLOW");
tprice = 349.00 * quantity;
break;
case 3:
printf("\nOrdered Item: FANTASY PILLOW");
tprice = 549.00 * quantity;
break;
case 4:
printf("\nOrdered Item: HEALTH PILLOW");
tprice = 599.00 * quantity;
break;
}
}else {
printf("Invalid Input!");
getch();
exit(0);
}
//Prompt Do you wish to continue
printf("\n\nDo you wish to continue?: y/n\n");
scanf("%s", &ans);
if ((ans=='y')||(ans=='Y'))
{ system("cls"); }
else
if ((ans=='n')||(ans=='N'))
{ exit(0);}
else
{ printf("\nInvalid Input! program will now exit");
exit(0);}
//Display Personal Info
char name, address, pcode, contact, e_add;
char mop, date, a;
printf("Please fill up your personal information");
printf("\n\nComplete Name: ");
scanf("%s", &name);
printf("Complete Address: ");
scanf("%s", &address);
printf("Postal Code: ");
scanf("%s", &pcode);
printf("Contact No: ");
scanf("%s", &contact);
printf("E-mail address: ");
scanf("%s", &e_add);
// Enter Code
printf("\n*********************************************");
printf("\n\nMode of Payment \tCode");
printf("\n\nBank Deposit \t\tA");
printf("\nMoney Transfer \t\tB");
printf("\n\n*********************************************");
printf("\nEnter the code of your chosen mode of payment:\n");
scanf("%s", &mop);
if((mop=='A')||(mop=='a')){
printf("\nMode of Payment: Bank Deposit");}
else
if((mop=='B')||(mop=='b')){
printf("\nMode of Payment: Money Transfer");}
else
{
printf("Invalid Input!");
getch();
exit(0);}
printf("\n\nDate of Payment: ");
scanf("%s", &date);
// Prompt do you wish to continue
printf("\nDo you wish to continue?: y/n\n");
scanf("%s", &ans);
if ((ans=='y')||(ans=='Y'))
{ system("cls"); }
else
if ((ans=='n')||(ans=='N'))
{ exit(0);}
else
{ printf("\nInvalid Input! program will now exit");
exit(0);}
//Display Claim Order
char code;
printf("How to claim your order \tCode");
printf("\n\nPick-up \t\t\tA");
printf("\nDelivery \t\t\tB");
//Enter DeliveryCode
printf("\n\nEnter code here: ");
scanf("%s", &code);
if((code=='A')||(code=='a')){
printf("\nOrder by: Pick-up");}
else
if((code=='B')||(code=='b')){
printf("\nOrder by: Delivery");}
else
{
printf("Invalid Input!");
getch();
exit(0);}
// Prompt do you wish to continue
printf("\n\nDo you wish to continue?: y/n\n");
scanf("%s", &ans);
if ((ans=='y')||(ans=='Y'))
{ system("cls"); }
else
if ((ans=='n')||(ans=='N'))
{ exit(0);}
else
{ printf("\nInvalid Input! program will now exit");
exit(0);}
printf("\n________________________________________________________________________________");
printf("\n\t\t\t\tORDER VERIFICATION\n");
printf("\n\nOrdered item: ");
{
if (item_code==1)
printf("Dream Pillow",item_code);
else
if(item_code==2)
printf("Bolster Pillow",item_code);
else
if(item_code==3)
printf("Fantasy Pillow",item_code);
else
if(item_code==4)
printf("Health Pillow",item_code);
}
printf("\nQuantity: %d\n",quantity);
printf("Total amount of purchased: %.2f\n", tprice);
//Prompt 1 or 2
printf("Complete name: %s\n", name);
printf("Complete Address: %s\n", address);
printf("Postal Code: %s\n", pcode);
printf("Contact Number: %s\n", contact);
printf("E-mail Address: %s\n", e_add);
printf("Mode of Payment: %s\n",mop);
printf("Claim your item thru: %s\n",code);
// Prompt do you wish to continue
printf("\n\nDo you wish to continue?: y/n\n");
scanf("%s", &ans);
if ((ans=='y')||(ans=='Y'))
{ system("cls"); }
else
if ((ans=='n')||(ans=='N'))
{ exit(0);}
else
{ printf("\nInvalid Input! program will now exit");
exit(0);}
//Display Merchant Details
printf("\n________________________________________________________________________________");
printf("\nPlease copy the merchant's details for sending your payments \n");
printf("\nFor Bank Deposit: \n");
printf("\tAccount name: Chin Go\n\tAccount number: 4444-8888-48\n\tName of bank: Banco de Oro\n");
printf("\nFor Money Transfer: \n");
printf("\tName: Chin Go\n\tContact No.: 888-8888\n\tAddress: Blk-88 Lot -01 Lucky Village, Pasig City\n");
printf("\n________________________________________________________________________________");
printf("\n\nDo you wish to continue?: y/n\n");
scanf("%s", &ans);
if ((ans=='y')||(ans=='Y'))
{ system("cls"); }
else
if ((ans=='n')||(ans=='N'))
{ exit(0);}
else
{ printf("\nInvalid Input! program will now exit");
exit(0);}
//Display transaction complete
printf("\n\n\n\n\n\n\n\t\t\t TRANSACTION COMPLETE\n");
printf("\t\tYour order was successfully sent. Please check\n\t\t\tyour e-mail for the invoice.");
printf("\n\n\t\t\tThank you for shopping!!!");
printf("\n\n\n\n\n\n\n\n\n\n\nAnother transaction?: y/n\n");
scanf("%s",&ans);
if ((ans=='y')||(ans=='Y'))
{ system("cls"); }
else
if ((ans=='n')||(ans=='N'))
{ exit(0);}
else
{ printf("\nInvalid Input! program will now exit");
exit(0);}
getch();
exit(0);
getch();
}