}
/*
else if (option == 2)
{
char cont;
int newID;
string descriptionNew;
int quantityNew;
double priceNew;
outfile.open(filename, ios::app);
while(outfile.good());
{
cout << "Enter "
}
}
else if (option == 4)
{
outfile.open(filename, ios::out);
for (int i = 0; i < )
}
*/
}
*Code is still incomplete, here's the sample input file:
2
1001
Remote
Control
Car
50
35.80
1002
Barbie Doll
75
45.00
The first line in the file should represent the number of records available in the file. The following lines represent the details of each record starting with the toy id, description, quantity, and price per unit.
When the program starts, prompt the user to enter the filename and read all toys’ information to be stored in the array of struct. You need to keep track of the total records available by declaring and using suitable variable as counter. The program should then display a menu that allows the user to perform the following operations:
View the different toys available in the store.
Add a new toy record
o For this option, prompt the user to enter all the toys information and add to the array of struct. You do not need to update the file yet at this moment.
Purchase toys
o The user should be allowed to select a toy from the list and determine the quantity to purchase.
o If there is sufficient quantity available for the purchase
deduct the purchased quantity from the toy’s record
Calculate and display the current total amount
o If the quantity is not sufficient, display an error message
o Then prompt the user whether another purchase is needed. If yes, repeat the process again
o If not, print the bill. This option should involve displaying the total due, prompt the user to enter the payment amount, and display the balance need to be paid back to the customer.
Display overall total of all purchases (you may need to consider additional variables to keep this information)
Update toy’s information
o Only description, quantity, and price per unit can be updated.
Quit from the program.
Purchasing a toy should also involve calculating discounts based on the quantity purchased. This should be done automatically when the purchase option is selected after the user has done the selection. Any purchase that exceeds 10 units is entitled for a 10% discount. Remember to update the record’s quantity every time a purchase is made. Use functions to perform each option provided in the menu (except the Quit option). Your program should also consider data validations. Before the program terminates, you
While slightly off your question you should use a better control structure like a switch and some functions, including a display menu function. It will have tha advantage of debugging and isolating problems.