Description of this paper

Loading

Hello.. can you help me to construct a flowchart based on the-(Answered)

Description

Step-by-step Instant Solution


Question

Hello.. can you help me to construct a flowchart based on the coding given ?? This is programming techniques .. I really really need your help.. Thank you very much :-?


#include <studio.h>

void receipt_top(char *customer, char *idnum, int phonenum, char *cashier);
void receipt_mid(char product[][15], int quantity, float totalprice,int k);
void receipt_end(float payment);

/*This is a program that takes the customer's order of shoes, calculate the total price and print a receipt for the customer.*/

int main(void)//function "main"
{
FILE*a;
a=fopen("products.txt","r");//opens file "products.txt"

//variable declaration
char product_name[5][15];
int i=0;
float price[5];

while(!feof(a))//reads the file
{
fscanf(a,"%s %f", &product_name[i], &price[i]);
i++;
}

fclose(a);//closes file

//=====================================================

//variable declaration
char customer[30], cashier[30], idnum[20];
int phonenum,quantity, choice, exit;
float totalprice, payment;
int k;


printf(" Enter your name : ");//asks for name
gets(customer);

printf("n Enter your ID number : ");//asks for id number
scanf(" %s", &idnum);

printf("n Enter your phone number : ");//asks for phone number
scanf(" %d", &phonenum);
fflush(stdin);

printf("n Cashier's name : ");//asks for cashier's name
gets(cashier);

receipt_top(customer,idnum,phonenum,cashier);//calls function "receipt_top"

//=====================================================

//shows type of shoes available and their prices
printf("n ---------------------------------");
printf("n Welcome to HZM Shoes Shop ^_^ n ");
printf("n ---------------------------------");
printf("n Type of shoes Price ");
printf("n ---------------------------------");

for(i=0;i {
printf("n t%stt%.2f", product_name[i], price[i]);
}
printf("n ---------------------------------");

//loop and selection for shoes
do
{

printf("nn Please choose your shoe brand [1-Adidas 2-Nike 3-Line7 4-Puma 5-Swiss] : ");
scanf(" %d", &choice);

if(choice==1)
{
printf("n Shoes : %s", product_name[0]);
printf("n Price : RM %.2f", price[0]);
printf("nn Enter quantity: ");
scanf(" %d", &quantity);
totalprice = quantity*price[0];
printf("n Total Price : RM %.2f",totalprice);

receipt_mid(product_name,quantity,totalprice,0);//calls function "receipt_mid"
}
else if(choice==2)
{
printf("n Shoes : %s", product_name[1]);
printf("n Price : RM %.2f", price[1]);
printf("nn Enter quantity: ");
scanf(" %d", &quantity);
totalprice = quantity*price[1];
printf("n Total Price : RM %.2f",totalprice);

receipt_mid(product_name,quantity,totalprice,1);//calls function "receipt_mid"
}
else if(choice==3)
{
printf("n Shoes : %s", product_name[2]);
printf("n Price : RM %.2f", price[2]);
printf("nn Enter quantity: ");
scanf(" %d", &quantity);
totalprice = quantity*price[2];
printf("n Total Price : RM %.2f",totalprice);

receipt_mid(product_name,quantity,totalprice,2);//calls function "receipt_mid"
}
else if(choice==4)
{
printf("n Shoes : %s", product_name[3]);
printf("n Price : RM %.2f", price[3]);
printf("nn Enter quantity: ");
scanf(" %d", &quantity);
totalprice = quantity*price[3];
printf("n Total Price : RM %.2f",totalprice);

receipt_mid(product_name,quantity,totalprice,3);//calls function "receipt_mid"
}
else if(choice==5)
{
printf("n Shoes : %s", product_name[4]);
printf("n Price : RM %.2f", price[4]);
printf("nn Enter quantity: ");
scanf(" %d", &quantity);
totalprice = quantity*price[4];
printf("n Total Price : RM %.2f",totalprice);

receipt_mid(product_name,quantity,totalprice,4);//calls function "receipt_mid"
}
else
{
printf("n Invalid choice");
}

printf("nn Any other choices? [1=Yes 0=No] : ");
scanf(" %d", &exit);

payment = payment+totalprice;//formula for payment

printf("n Payment Needed : %.2f", payment);

} while(exit!=0);

receipt_end(payment);//calls function "receipt_end"

return 0;
}

void receipt_top(char *customer, char *idnum, int phonenum, char *cashier)//function "receipt_top"
{
FILE*b;
b=fopen("receipt.txt","w");//creates "receipt.txt" and write the following argument into the document

fprintf(b,"============================================");
fprintf(b,"n HZM Shoes Shop ^_^");
fprintf(b,"nn============================================");
fprintf(b,"n CUSTOMER INFORMATION" );
fprintf(b,"n--------------------------------------------");
fprintf(b,"nCustomer Name: %s", customer);
fprintf(b,"nCustomer ID: %s", idnum);
fprintf(b,"nCustomer's Phone Number: %d", phonenum);
fprintf(b,"nCashier ID: %s", cashier);
fprintf(b,"n--------------------------------------------");

fclose(b);
}

void receipt_mid(char product[][15], int quantity, float totalprice,int k)//function "receipt_mid"
{
FILE*b;
b=fopen("receipt.txt","a");//appends to "receipt.txt"

fprintf(b,"n Item: %s", product[k]);
fprintf(b,"n Quantity: %d Price: RM%.2fn", quantity,totalprice);

fclose(b);
}

void receipt_end(float payment)//function "receipt_end"
{
FILE*b;
b=fopen("receipt.txt","a");//appends to "receipt.txt"

fprintf(b,"n--------------------------------------------");
fprintf(b,"nnn Total Price: RM%.2f",payment);
fprintf(b,"nn--------------------------------------------");
fprintf(b,"n Thanks for purchasing from our shop :D");
fprintf(b,"n Please come again!!!");
fprintf(b,"n============================================");

fclose(b);
}


 

Paper#9256863 | Written in 27-Jul-2016

Price : $16
SiteLock