C Question is too long so I created links to ask as seperate

_____C#_____

Question is too long, so I created links to ask as seperate questions

https://www.chegg.com/homework-help/questions-and-answers/c-program-display-two-options-beginning-program-customer-manager-customer-new-customer-pro-q16507445

https://www.chegg.com/homework-help/questions-and-answers/c-console-application-program-display-two-options-beginning-program-customer-manager-manag-q16507515

In this assignment, you will create your own online 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. You can create your discount level rule or use the rule in the assignment 4.

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 the HEB 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 to text files to keep all the information the program need. You can check some on-line store to get some ideas (Amazon, Walmart …). Make sure your program does not end unexpectedly and let user have the option to continue.  

Solution

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <fstream.h>
#include <process.h>
#include <stdlib.h>

class list
    {
    int count;
    char serial[30][30];
    char name[30][30];
    char price[30][30];
    char quality[30][30];
    char quantity[30][30];
    public:
    void goods();
    void order_goods();
    void show_goods();
    };

void list::order_goods()
    {
    char pid[30];
    long qid;
    int found=0;
    cout<<\"Enter Product id: \";
    cin>>pid;
    int v;
    for(v=0;v<count;v++)
    {
    if(strcmp(serial[v],pid)==0)
        {
        found=1;
        break;
        }
    }
    if(found==1)
    {
    char read;
    cout<<\"Enter quantity(kg): \";
    cin>>qid;
    AA:
    cout<<\"Are you sure of ordering \"<<qid<<\" kg of \"<<name[v];
    cout<<\"\ Enter (y/n)\";
    cin>>read;
    if(read==121)
    {
    fstream fout;
    fout.open(\"list.txt\",ios::out);
    long sum=0;
    int d=1;
    for(int s=strlen(quantity[v])-1;s>=0;s--)
        {
        sum+=(quantity[v][s]-48)*d;
        d*=10;
        }
    sum+=qid;

    //sum=(long)quantity[v];
    //cout<<\"sum\"<<sum;

    itoa(sum,quantity[v],10);

    for(int m=0;m<count;m++)
        {
        fout<<serial[m]<<\";\";
        fout<<name[m]<<\";\";
        fout<<price[m]<<\";\";
        fout<<quality[m]<<\";\";
        fout<<quantity[m]<<\";\"<<\"\ \";
        }
        long ati=atoi(price[v])*qid;
    cout<<\"\ \"<<ati <<\" taka has been truncated from shop account\ \";
    }
    else if(read==110);
    else
    {
    clrscr();
    goto AA;
    }
    //char y=\'n\';
    //printf(\"%d\",y);
    }
    }
void list::goods()
    {
    char pricestr[20];
    char str[2000];
    ifstream fin;
    fin.open(\"list.txt\",ofstream::in);

    //char s[2000];
    count=0;
    while(fin>>str)
    {

    int savei=0;
    //cout<<str;
    //   cout<<strlen(str)<<\" \";
    int i=0;
    int d=0;
    while(i<strlen(str))
    {

    if(str[i]==\';\')
        {

    //cout<<\"Savei=\"<<savei<<\"\\t\"<<\"i=\"<<i<<\" \";
    char s[30];
    int l=0;
    for(int j=savei;j<i;j++)
          {
          s[l]=str[j];
          l++;
          }
          s[l]=\'\\0\';
    if(d==0)
    strcpy(serial[count],s);
    else if(d==1)
    strcpy(name[count],s);
    else if(d==2)
    strcpy(price[count],s);
    else if(d==3)
    strcpy(quality[count],s);
    else if(d==4)
    strcpy(quantity[count],s);
    d++;
       //cout<<\"strlen=\"<<l<<\",s=\"<<s<<\"\ \";
    //char tab=\'\\t\';
    //printf(\"%5c\",tab);

       i++;
       savei=i;
        }
    //printf(\"%c\",str[i]);

    i++;

    }
    count++;
    if(fin.eof())
    break;
    //cout<<\"\ \";
    }
    fin.close();


      }
      void list::show_goods()
      {
      cout<<\"p-id\\t name\\t price\\t   quality\\tquantity(kg)\ \";
    cout<<\"-----------------------------------------------------------\ \";
      for(int v=0;v<count;v++)
    {
    printf(\"%s\",serial[v]);
    printf(\"%8s\",name[v]);
    printf(\"%8s\",price[v]);
    printf(\"%15s\",quality[v]);
    printf(\"%10s\",quantity[v]);
    printf(\"\ \");
    }
      }
void main()
{
A:
clrscr();
cout<<\"Make your choice:\ [1] For see products\ [2] For order products\ [3] For quit\ \ \";
list ob;
char a;
cin>>a;
clrscr();
ob.goods();
if(a==49)
ob.show_goods();
else if(a==50)
ob.order_goods();
else if(a==51)
exit(0);
else
goto A;
cout<<\"\ \ Press any key to return to Main Menu.\";
getch();
goto A;

}

_____C#_____ Question is too long, so I created links to ask as seperate questions https://www.chegg.com/homework-help/questions-and-answers/c-program-display-t
_____C#_____ Question is too long, so I created links to ask as seperate questions https://www.chegg.com/homework-help/questions-and-answers/c-program-display-t
_____C#_____ Question is too long, so I created links to ask as seperate questions https://www.chegg.com/homework-help/questions-and-answers/c-program-display-t
_____C#_____ Question is too long, so I created links to ask as seperate questions https://www.chegg.com/homework-help/questions-and-answers/c-program-display-t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site