Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Class Question My code: #include <iostream> using namespace std; class Purchase

ID: 3538327 • Letter: C

Question

Class Question


My code:


#include <iostream>

using namespace std;

class Purchase
{
    private:
            char name;
            int qty;
            float price, total;

    public:
            void set_data(char, int, float);
            void calculate(float);
            void print();

};

void Purchase::set_data(char a, int b, float c)
{
    name=a;
    qty=b;
    price=c;



    cout<<"Enter name:";
    cin.get(name);
    cout<<"Enter quantity:";
    cin>>qty;
    cout<<"Enter price:";
    cin>>price;
    cin.ignore();

}

void Purchase::calculate(float d)
{

    total=d;

    total=qty*price;

}

void Purchase::print()

{

    cout<<"Name         :"<<name;
    cout<<"Quantity     :"<<qty;
    cout<<"Price        :"<<price;
    cout<<"Payment      :"<<total;
    cout<<endl;
}

int main()
{
    Purchase p;

    char name;
    int qty;
    float price, total;


    cout<<"=============================="<<endl;
    cout<<"           WELCOME            "<<endl;
    cout<<"=============================="<<endl;

    p.set_data(name,qty,price);

    p.calculate(total);

    p.print();


    return 0;
}



Help me correct where my false in this question, then post in full code.

and explain it.


Thank

Explanation / Answer

#include using namespace std; class Purchase { private: char name; int qty; float price, total; public: void set_data(char, int, float); void calculate(float); void print(); }; void Purchase::set_data(char a, int b, float c) { name=a; qty=b; price=c; cout