Jump to content
Sign in to follow this  
ipsian

Sistem Dobi C++

Recommended Posts

im tried to settle this problem but have 1 error..

the Q

the ABC Company is small loundry that usus a special system to calculate the price for customer. the system calculation are as follow:

type price

1. Shirt $15 per kg

2. Blanket $ 6 per kg

3. Comforter $10 per kg

at one time only one type from the above type is allowed. the loundry also given some discount to it customer base on the foolowing price.

price total discount

>=$30 10% of price total

>=$20 5% of price total

>=$15 3%

<=$14 0%

calculate the price that has to be paid by customer. the output must produce are as follow

ABC COMPANY

no. of customer :

Price Total :

Discount :

price to be paid:

Next Customer (Y/N)...

my coding... but still have 1 error

#include <iostream.h>
#include <stdlib.h> // for system("pause") and system("cls")
#include <math.h> // for sqrt()
#include <conio.h>

void GetData(float & First, float & Second);
float Shirt(float First, float Second);
float Blanket(float First, float Second);
float Comforter(float First, float Second);


int main()


    {
    float First, Second, Answer, Discount, PaidTotal;
    int Choice;
    
    bool Quit = false;
    while(!Quit)


            {
            cout << "*******Menu*******" << endl;
            cout << "1) Shirt" << endl;
            cout << "2) Blanket" << endl;
            cout << "3) Comforter" << endl;
            cout << "4) Quit" << endl;
            cout << "******************" << endl;
            cin >> Choice;
            
PaidTotal=Answer-Discount;
            
        
            
            switch(Choice)


                {
                case 1:

                    {
                       GetData(First, Second);
                      Answer = Shirt(First, Second);
                       cout << " $ " << Answer << endl;
                       cout<<PaidTotal;
                    break;
                       }
                  case 2:

                        {
                         GetData(First, Second);
                                Answer = Blanket(First, Second);
                                cout <<" $ " << Answer << endl;
                                break;
                            }
                        case 3:


                                {
                                    GetData(First, Second);
                                    Answer = Comforter(First, Second);
                                    cout << " $ " << Answer << endl;
                                    break;
                                }
                        
                                                            default:


                                                                    {
                                                                        return 0;
                                                                        break;
                                                                    }
                                                                }
                                                                system("pause");
                                                                system("cls");
                                                                }
                                                            return 0;

}

                                                            
                                                                        {

                                                                         if (Answer >=30)
                                                                        {
                                                                        Discount=0.10*Answer;
                                                                        }
                                                                        else if (Answer >=20)
                                                                        {
                                                                        Discount=0.05*Answer;
                                                                        }
                                                                        else if (Answer >=15)
                                                                        {
                                                                        Discount=0.03*Answer;
                                                                        }
                                                                        else if (Answer >=1)
                                                                        {
                                                                        Discount=0*Answer;
                                                                        }
                                                                        else
                                                                        cout<<"0";
                                                            
                                                                
                                                        



                                                        void GetData(float & First, float & Second)


                                                            {
                                                                cout << "Enter the weight: ";
                                                                cin >> First;
                                                                cout << "Price per Kg: RM ";
                                                                cin >> Second;
                                                                cout << "Total Price: ";
                                                                cout << "Discount: "<<Discount;
                                                                cout << "Price to be paid:<<PaidTotal ";

                                                                
            
                                                        }

                                                        float Shirt(float First, float Second)


                                                            {
                                                                return First * Second;
                                                        }

                                                        float Blanket(float First, float Second)


                                                            {
                                                                return First * Second;
                                                        }

                                                        float Comforter(float First, float Second)


                                                            {
                                                                return First * Second;
                                                        }
                                                            }

Share this post


Link to post
Share on other sites

kindly re-arrange your coding... to many open and closing brackets!! But i'm sure that you make mistake because there are too many "opening" rather than "closing"!!

Edited by mfar

Share this post


Link to post
Share on other sites

Logical error kot?

I don't see any unclosed bracket(s)?

But yes, need to re-arrange maybe.

And I found this, but still doesn't solve the error:

cout << "Discount: "<<Discount;
cout << "Price to be paid:<<PaidTotal ";//misplace closing " sign---PaidTotal unreferred variable warning//

Share this post


Link to post
Share on other sites

Logical error kot?

I don't see any unclosed bracket(s)?

But yes, need to re-arrange maybe.

And I found this, but still doesn't solve the error:

cout << "Discount: "<<Discount;
cout << "Price to be paid:<<PaidTotal ";//misplace closing " sign---PaidTotal unreferred variable warning//

alhamdulillah.. semuanya dah setel.... terpaksa ubah sikit sebanyak... tak pakai function tapi guna nested if else dan switch saje..

anyway kepada yg sudi membantu.. thanks a lot

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...