Please help me with my project. Currently i am trying to make a receipt that only list the things that you order. But i have no idea how to do it. Please Help

#include <iostream>

#include <stdlib.h>

using namespace std;

void check ();

void start();
void printacc(double pa);
void printphone(double pp);
void printsum(double sum);
void comm(double sum);

void namep(int a);
void namea(int numa);
void cust ();

int menu, phone, acc, nump, numa, num1, num2, num3, num4, num5, num6, num7, num8;
double sum, pp, pa;
string noP, name;

int main()
{

    pp = 0;
    pa = 0;
    sum = 0;
    nump=0;
    numa=0;

    start();
    cout<<"\t";
    system ("PAUSE");

    system ("CLS");

    cout << "Enter your name : "; cin>> name;
    cout << "Enter your phone number : "; cin>> noP;
    system ("PAUSE");


    do{  //repeat until they choose end

    system ("CLS");

    cout << "\n\n\n\t\t======== Phone Store ========\n";
    cout << "\t\t1. Buy phone\n";
    cout << "\t\t2. Buy accesory\n";
    cout << "\t\t3. Delete all order\n";
    cout << "\t\t4. Check order\n";
    cout << "\t\t5. End order\n\n";

    sum= pa +pp;
    printsum(sum);
    cout<<"\n";

    cout << "\t\tChoose what you want to do: ";
    cin >> menu;
    cout << "\n\n"<<flush;



switch (menu)

    {

        system ("CLS");

case 1:    //Buy phone
    cout << "\n\n\t====== Choose the phone you desire <3 ======\n\n";
    cout << "\t1 \tXiaomi Poco M3 Pro 5G\t\tRM 599\n";
    cout << "\t2 \tAsus Zenfone 8 Flip\t\tRM 2899\n";
    cout << "\t3 \tVivo V21 5G 256GB\t\tRM 1899\n";
    cout << "\t4 \tXiaomi Redmi Note 10S\t\tRM 799\n\n";

    cout << "\t\t(Please enter 1,2,3 or 4)\n";
    cout << "\t\tYour choice: ";cin >> phone;

        cout<< "\n\t\tHow many do you want it?";
        cout<< "  =";cin>> nump;
        cout <<flush;

                switch(phone){
                    case 1:
                        pp =pp+ 599 * nump;
                        num1=nump;
                        break;

                    case 2:
                        pp =pp+ 2899 * nump;
                        num2=nump;
                        break;

                    case 3:
                        pp =pp+ 1899 * nump;
                        num3=nump;
                        break;

                    case 4:
                        pp =pp+ 799 * nump;
                        num4=nump;
                        break;

                    default:
                        cout<< "\n\t\tPlease enter a valid number!!\n";
                        cout<<"\t\t";
                        system ("PAUSE");
                        break;
    }
break;


case 2:  //buy accessory

    cout << "\n\n\t====== Choose the accesory you desire <3 ======\n\n";
    cout << "\t1 \tMobile Phone Stand Holder\t\tRM 5.00\n";
    cout << "\t2 \tOriginal Pineng Powerbank 20000mAh\tRM 33.00\n";
    cout << "\t3 \tSamsung Wireless Charger\t\tRM 159.00\n";
    cout << "\t4 \tEdifier X3 Plus\t\t\t\tRM 89.00\n\n";

    cout << "\t\t(Please enter 1,2,3 or 4)\n";
    cout << "\t\tYour choice: ";cin >> acc;

        cout<< "\n\t\tHow many do you want it?";
        cout<< "  =";cin>> numa;

                switch(acc){
                    case 1:
                        pa = pa +  5 * numa;
                        num5=numa;
                        break;

                    case 2:
                        pa = pa+  33 * numa;
                        num6=numa;
                        break;

                    case 3:
                        pa =pa + 159 * numa;
                        num7=numa;
                        break;

                    case 4:
                        pa = pa +  89 * numa;
                        num8=numa;
                        break;

                    case 5 :
                        break;break;

                    default:
                        cout<< "\n\t\tPlease enter a valid number!!\n";
                        cout<<"\t\t";
                        system ("PAUSE");
                        break;
                }
                break;
case 3:  //cancel order/delete all order/reset
    pp = 0;
    pa = 0;
    sum = 0;
    nump=0;
    numa=0;
    num1=0;
    num2=0;
    num3=0;
    num4=0;
    num5=0;
    num6=0;
    num7=0;
    num8=0;
    break;

case 4:
    check();
    cout<<"\t\t";
    system ("PAUSE");
    break;

case 5:  // end order
    break;

default: 
cout<< "\n\t\tPLEASE PUT A VALID NUMBER\n";
cout<<"\t\t";
system ("PAUSE");
   }
    }while(menu != 5);

    cout << "\n\t\t====================== End =======================\n";

    sum = pa +pp;
    cust();
    namep(nump);
    namea(numa);

    printphone(pp);
    printacc(pa);
    cout<<"\t\t";printsum(sum);
    comm(sum);


    cout << "\n\t\t================== Thank you <3 ==================\n";


    return 0;
}

void printsum(double sum)//write sum price
{
    cout << "\t\tTotal \t\t: RM"<< sum <<endl;
}

void printphone(double pp)//write sum phone price they bought
{
    cout << "\n\t\t\t\tSum phone \t: RM" << pp<<endl;
}

void printacc(double pa)//write sum accessory price they bought
{
    cout << "\t\t\t\tSum accessory \t: RM" << pa<<endl;
}

void comm(double sum)//worker commission
{
    cout<< "\t\t\t\tWorker commision: RM" << sum *0.05<< endl;
}

void start() //Greeting
{
     cout << "        =====================================================================\n\n";
    cout << "\t\t\t Welcome to our phone store!!\n\n";
    cout << "\t 1. You can choose whatever you want to buy in this store.\n\n";
    cout << "\t 2. This program will be repeated until you choose to end your order.\n\n";
    cout << "\t 3. If you have a change of heart you can reset your order by the \n\t   'delete all order' option.\n\n";
    cout << "\t 4. Take your time. 'There's no reason rush'\n\n";
    cout << "\t 5. Enjoy your shopping here.<3\n\n";
     cout << "        =====================================================================\n\n";

    cout << "\n";
}

void namep(int nump)
{
        cout << "\n\t\tPhone :";
        cout << "\n\t\tXiaomi Poco M3 Pro 5G\t\tx " << num1 << "  [ RM 599  ]";
        cout << "\n\t\tAsus Zenfone 8 Flip\t\tx " << num2 << "  [ RM 2899 ]";
        cout << "\n\t\tVivo V21 5G 256GB\t\tx " << num3 << "  [ RM 1899 ]";
        cout << "\n\t\tXiaomi Redmi Note 10S\t\tx " << num4 << "  [ RM 799  ]" << "\n\n";

}


void namea(int numa)
{
        cout << "\t\tAccessory :";
        cout << "\n\t\tMobile Phone Stand Holder\tx " << num5 << "  [RM 5.00  ]";
        cout << "\n\t\tOriginal Pineng Powerbank \tx " << num6 << "  [RM 33.00 ]";
        cout << "\n\t\tSamsung Wireless Charger\tx " << num7  << "  [RM 159.00]";
        cout << "\n\t\tEdifier X3 Plus\t\t\tx " << num8 << "  [RM 89.00 ]"  ;
        cout << "\n\n";

}

void check ()
{
    namep(nump);
    namea(numa);
}

void cust ()
{
    cout << "\n\t\tCustomer name \t\t  : "<< name;
    cout<< "\n\t\tCustomer's contact number : "<< noP<<endl;
}

At 276 lines long I won't read all that. Tell us what you think the issue or problem is, then where in this code to look.

PS. I see you used system(). http://www.cplusplus.com/articles/j3wTURfi/ and many other artilces note why this is never a good idea. In fact I think this alone should warrant a failing grade on the assignment. Teach security from day one!

I'm sorry. It's my first time learning c++ and trying to post it online. I just wanna ask what can I improve in this coding to get better grade.

Clear screen in character based apps would have to know all the details to make it function. For ncurses work: https://linux.die.net/man/3/clear

For other OSes we look at what is in use. I haven't seen a pure DOS system in over 3 decades so there's always another way.
The compiler matters too.

If your code works and the class has not touched on security yet, you can get by for now with system().

All you have to do is compare the counters against 0. How did your assignment turn out?

void namep(int nump)
{
        cout << "\n\t\tPhone :";
        if (num1 > 0) {
            cout << "\n\t\tXiaomi Poco M3 Pro 5G\t\tx " << num1 << "  [ RM 599  ]";
        }
        if (num2 > 0) {
            cout << "\n\t\tAsus Zenfone 8 Flip\t\tx " << num2 << "  [ RM 2899 ]";
        }
        if (num3 > 0) {
            cout << "\n\t\tVivo V21 5G 256GB\t\tx " << num3 << "  [ RM 1899 ]";
        }
        if (num4 > 0) {
            cout << "\n\t\tXiaomi Redmi Note 10S\t\tx " << num4 << "  [ RM 799  ]" << "\n\n";
        }
        cout << "\n\n";
}


void namea(int numa)
{
        cout << "\t\tAccessory :";
        if (num5 > 0) {
            cout << "\n\t\tMobile Phone Stand Holder\tx " << num5 << "  [RM 5.00  ]";
        }
        if (num6 > 0) {
            cout << "\n\t\tOriginal Pineng Powerbank \tx " << num6 << "  [RM 33.00 ]";
        }
        if (num7 > 0) {
            cout << "\n\t\tSamsung Wireless Charger\tx " << num7 << "  [RM 159.00]";
        }
        if (num8 > 0) {
            cout << "\n\t\tEdifier X3 Plus\t\t\tx " << num8 << "  [RM 89.00 ]";
        }
        cout << "\n\n";
}


    E.g.,
            Phone :
            Asus Zenfone 8 Flip             x 3  [ RM 2899 ]

            Accessory :
            Original Pineng Powerbank       x 1  [RM 33.00 ]
            Samsung Wireless Charger        x 1  [RM 159.00]


                            Sum phone       : RM8697
                            Sum accessory   : RM192
                            Total           : RM8889
                            Worker commision: RM444.45

            ================== Thank you <3 ==================
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.