The document describes a program that allows customers to be added, their information edited, and their information displayed. It includes the following functions:
1. ADD() - Allows a customer's first name, item name, price, quantity, total amount, and discounted amount to be input and calculated based on quantity and price. Different discount rates are applied based on total amount.
2. EDIT() - Displays all customer information and allows editing of a selected customer's first name, item name, quantity, or price.
3. Display() - Displays all customer information and allows returning to the main menu or exiting.
2. Batch 3
Design a program that will accept
a maximum of 5 customers.
3. If your choice is 1: -------------- void ADD()
First name:
• printf("FIRST NAME:"); scanf("%s",&name[x]); getchar();
Name of item:
• printf(“ITEM NAME:"); scanf("%s",&item[x]); getchar();
Price:
• printf("PRICE:"); scanf("%d",&price[x]);
Quantity:
• printf("QUANTITY:"); scanf("%d",&qty[x]);
• Clear the previous display ----------------- clrscr();
• Accept the following:
4. Then compute for total amount,
where total amount is:
price * quantity.
• totalAmt[x]=price[x]*qty[x];
5. • If total amount is lesser than or equal to 1000, give 5% discount.
Compute for total discounted amount, where:
Total Discounted Amount is Total Amount – Discounted Amount.
Display Total Discounted Amount.
• Else if total amount is greater than 1000, but less than or equal to 2000,
give 10% discount. Compute for total discounted amount, where:
Total Discounted Amount is Total Amount – Discounted Amount.
Display Total Discounted Amount.
• Else if total amount is greater than 2000, but less than 5000, give 15%
discount. Compute for total discounted amount, where:
Total Discounted Amount is Total Amount – Discounted Amount.
Display Total Discounted Amount.
• Else give 20% discount. Compute for total discounted amount, where:
Total Discounted Amount is Total Amount – Discounted Amount.
Display Total Discounted Amount
7. After all the inputs, ask “DO YOU
WANT TO GO TO MAIN MENU? 1
for YES | 2 for NO”…
• If 1 go to Main Menu or Main Display
if(opt==1) { MAIN(); }
• If 2 Exit
else { exit(0);}
8. If your choice is 2: -------------- void EDIT()
• Clear the previous display ----------------- clrscr();
• Display “NO RECORDS AVAILABLE” if no information of
entrepreneurs that were added.
• Else, display all information of customer.
• If you wish to edit the information of customer, display “DO
YOU WANT TO EDIT INFORMATION?
1 for YES | 2 for NO”
• If you entered 1, accept a number from list you want to edit.
Display EDIT MENU.
• Choose what field of information you would like to edit.
9. • If your choice is 1, then EDIT the FIRST NAME only
• If your choice is 2, EDIT the ITEM NAME
• If your choice is 3, EDIT the QUANTITY
• If your choice is 4, EDIT the PRICE
• After all the inputs, ask “DO YOU WANT TO GO TO MAIN
MENU? 1 for YES | 2 for NO…
• If 1 go to Main Menu or Main Display
if(opt==1) { MAIN(); }
• If 2 Exit
else { exit(0);}
10. EDIT INFORMATION
FIRST NAME ITEM QUANTITY PRICE TOTAL AMOUNT TOTAL DISCOUNTED AMOUNT
1. Khatt bag 2 950 19,000 18,620
2. Jenny pen 5 100 500 495
Do you want to edit information? 1 for YES | 2 for NO: 1
Enter a number from the list: 1
Choose what field to edit:
• FIRST NAME
• NAME OF ITEM
• QUANTITY
• PRICE
ENTER YOUR CHOICE: 1
************************** EDIT CUSTOMER’S INFORMATION ************************
ENTER FIRST NAME: firstname
Do you want to go to Main Menu? 1 for YES | 2 for NO:
11. void EDIT()
{ clrscr();
if(x==0)
{ printf("NO RECORDS AVAILABLE!"); }
else
{ printf("ALL INFORMATION of CUSTOMER");
printf("FIRST NAME ITEM QTY PRICE AMOUNT DISCOUNTED AMT");
for (y=1; y<=x; y++)
{
printf("%d. %s %s %d %d %d %f",y, name[y],item[y],qty[y],price[y],totalAmt[y],disc[y]); }
printf("DO YOU WANT TO EDIT INFORMATION? 1 for YES | 2 for NO:");scanf("%d",&num);
if(num==1)
{ printf ("ENTER A NUMBER FROM THE LIST: "); scanf("%d",&number);
printf (“ CHOOSE WHAT FIELD TO EDIT:");
printf (“ 1. FIRST NAME");
printf (“ 2. NAME OF ITEM");
printf (“ 3. QUANTITY");
printf (“ 4. PRICE");
printf (" ENTER YOUR CHOICE: "); scanf("%d",&ch);
switch(ch)
12. switch(ch)
{ clrscr();
case 1: printf (“ ENTER FIRST NAME:"); scanf("%s",&name[number]); getchar();
break;
case 2: printf (“ ENTER NAME OF ITEM:"); scanf("%s",&item[number]); getchar();
break;
case 3: printf (“ ENTER QUANTITY:"); scanf("%d",&qty[number]);
break;
case 4: printf (“ ENTER PRICE:"); scanf("%d",&price[number]);
break;
}
printf("DO YOU WANT TO GO TO MAIN? 1 for YES | 2 for NO:");scanf("%d",&opt);
if(opt==1)
{ MAIN(); }
else { exit(0); }
else
{ exit(0); }
}}
13. If your choice is 3: -------------- void Display()
• Clear the previous display ----------------- clrscr();
• Display “NO RECORDS AVAILABLE” if no information of
entrepreneurs that were added.
• Else, display all information of customer.
• If you wish to edit the information of customer, display “DO
YOU WANT TO EDIT INFORMATION?
1 for YES | 2 for NO”
• If 1 go to Main Menu or Main Display
if(opt==1) { MAIN(); }
• If 2 Exit
else { exit(0);}
14. void Display()
{
clrscr();
printf("DISPLAY INFORMATION");
if(x==0)
{ printf (“NO RECORDS AVAILABLE!"); }
else
{
printf (“ FIRST NAME ITEM QTY PRICE AMOUNT DISCOUNTED AMT");
for (y=1; y<=x; y++)
{
printf("%d. %s %s %d %d %d %f",y, name[y],item[y],qty[y],price[y],totalAmt[y],disc[y]); }
printf(" DO YOU WANT TO GO TO MAIN? 1 for YES, 2 for EXIT: ");
scanf("%d",&opt);
if(opt==1)
{ MAIN(); }
else
{ exit(0); }
}}