#include <iostream>
#include <iomanip>
using namespace std;


int main()

{


    char item, code [5] ;
    double number, money;

    const double itemA=50, itemB=60, itemC=70, disc=0.8;
    const int size = 10;

    cout <<"Enter the item you would like to buy: A,B, or C: ";
    cin >> item;

    cout <<"Enter how many you would like to buy: ";
    cin >> number;


    cout << "Enter the passcode: ";
    cin>>code;

    cout << fixed << showpoint << setprecision(2);

    if (item == 'A' || item == 'B' || item == 'C')
    {
        if (item == 'A' && code =='DISC')
            money = number * 0.8 * itemA;
            cout << "Your total is $" << money;
        else if (item == 'A')
            money =number *itemA;
            cout << "Your total is $" << money;
        else if (item =='B')
            money = number * itemB;
            cout <<"Your total is $" << money;
        else if (item =='C' && number <20)
            money = number * itemC;
            cout << "Your total is $" << money;
        else if (item =='C' && number >20 && number <50)
            money = number * 0.75 * itemC;
            cout << "Your total is $" << money;
        else if (item == 'C' && number >50)
            money = number * 0.7 * itemC;
            cout << "Your total is $" << money;
    else

        if (number <0)
            cout << "ERROR - Not a positive amount" << endl;
        else if (number >0)
            cout << "ERROR - Run program again and enter item A,B,or C" << endl;

    }





    system ("pause");
     return 0;

    }

I posted what I supposed to do.

Edited 3 Years Ago by Dani: Formatting fixed

Attachments Image0001.jpg 228.95 KB

What does the program not do that you want it to do? What are the errors? We are not here to debug and fix errors in your program, but to help you do it yourself. But before we can do that you have to know what te problems are.

Sorry. I forgot to mention what I want. The error is '==' : no conversion from 'int' to 'char *' and illegal else without matching if.

Use Code tags

else if (item == 'A')
money =number *itemA;
cout << "Your total is $" << money;

should be

else if (item == 'A'){
money =number *itemA;
cout << "Your total is $" << money;
}

that is

if(....){
//=============
}
else if(...){
//==========
}
else if(...){
//=============
}
else{
//============
}

I fixed { } this part, but I still had a problem with '==' : no conversion from 'int' to 'char *'. What is wrong with my code?

char item, code[5];


else if (item == 'A')
        {   
            cout << "Enter the passcode: ";
            cin>>code;

            if (code == 'DISC')
            {
                money =number *itemA* 0.8;
                cout << "Your total is $" << money<< endl;
            }
            else 
            {
                money = number * itemA;
                cout << "Your total is $" << money << endl;
            }

Edited 3 Years Ago by Dani: Formatting fixed

This article has been dead for over six months. Start a new discussion instead.