C# Application. In this assignment you will create your own on-line shopping sto
ID: 3801362 • Letter: C
Question
C# Application.
In this assignment you will create your own on-line shopping store in the console application. You can choose different products to sell in your store (at least 8 products). You will create an product inventory text file.
The program will display two options at the beginning of the program, Customer and Manager.
Customer:
If this is a new customer, the program will let customer to register with their information and assign a unique ID number to the new customer.
The customer will enter the customer id every time when they are shopping in your store and the program will keep tracking the total amount the customer spend each time to determine the discount level.
The amount of a customer’s discount is determined by the amount of the customer’s cumulative purchases in the store as follows:
When a preferred customer spends $500, he or she gets a 5% discount on all future purchases.
When a preferred customer spends $1000, he or she gets a 6% discount on all future purchases.
When a preferred customer spends $1500, he or she gets an 8% discount on all future purchases.
When a preferred customer spends $2000, he or she gets a 10% discount on all future purchases.
The program has to keep tracking the products inventory. If customer select the product that is out of stock, the program has to display a warning message and let customer continue to shop. After customer finish selecting the products, the program will calculate the subtotal, apply the discount, calculate the tax, and the total. The program will display a receipt on the screen and save it to a text file with customer information. (Just like a receipt).
Manager:
The manager option has to be password protected. The program will give the manager two option:
Display the inventory: display all the products stock information
Restock the products: add more stock for each product
You have to create different classes and utilize the inheritance features. You have two text files to keep all the information the program need. Make sure your program does not end unexpectedly and let user have the option to continue.
Explanation / Answer
#include <stdio.h>
#include <string.h>
int recordLength = 3;
int maxchar = 6;
struct customer{
int custid;
char customerName[6];
};
int main()
{
int recordUpdated = 0;
int choice;
char name[6] = { '' };
int isDone = 0;
struct customer customerAarry[recordLength];
int indx = 0;
// default intialization
for( ; indx < recordLength ; indx++){
int j=0;
for( ; j < maxchar ; j++){
customerAarry[indx].customerName[j] = '';
customerAarry[indx].custid = -1;
}
}
while(isDone == 0){
printf("Choose one of the following option ");
printf("1. Manager ");
printf("2. Customer ");
printf("3. Exit");
printf("4. Display Customer ");
scanf("%d",&choice);
if(choice == 2){
printf("Enter Customer Name in 6 char length : ");
scanf("%s",&name);
int customerToBeAdded = 0;
int customerExit = 0;
printf("Process starts for %s : " , name);
if(strlen(name) > 0){
int indx = 0;
int inx = 0;
int count = 0;
// check the existance of customer
for( ; indx < recordLength ; indx++){
int j=0;
for( ; j < maxchar ; j++){
if(customerAarry[indx].customerName[j] == name[j]){
count++;
}
}
if(count == maxchar){
customerExit = 1;
}
}
if(customerExit == 1){
printf(" Customer name already exist at location %d ", indx);
}
if(customerAarry[customerToBeAdded].custid == -1){
printf(" Customer does not exist. it needs to be inserted ar %d ", customerToBeAdded);
}
// insert record
int j = 0;
if(recordUpdated <= recordLength){
for( ; j < strlen(name) ; j++ ){
customerAarry[recordUpdated].customerName[j] = name[j];
}
customerAarry[recordUpdated].custid = recordUpdated;
recordUpdated = recordUpdated +1;
}
}else{
printf("Invalid Customer Name ");
}
}else if(choice == 3 ){
isDone = 1;
}else if(choice == 4){
int indx = 0;
for( ;indx < recordLength ; indx++){
printf(" Customer Name %s ",customerAarry[indx].customerName);
printf(" Customer ID %d ",customerAarry[indx].custid);
}
}
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.