🔒 Closed Pahelp

Status
Not open for further replies.
C++:
#include <iostream>
using namespace std;

int main()
{
    string itemName;
    float price;
    int quantity;
    float subtotal=0, total=0, discount=0;
    char decision, withDiscount;

    do {


        cout << endl << "Item name: ";
        cin >> itemName;
        cout << "Enter price : ";
        cin >> price;
        cout << "Enter quantity: ";
        cin >> quantity;
        cout << "__________________ " << endl;
        subtotal = price * quantity;
        
        printf("Total: %.2f\n", subtotal);
        total = total + subtotal;
    
        printf("GRAND TOTAL: %.2f\n\n", total);
        
        
        cout << "Add another item? Y/N: ";
        cin >> decision;
        decision = toupper(decision);

        if (decision != 'Y')
        {
            cout << "With discount? Y/N: ";
            cin >> withDiscount;
            withDiscount = toupper(withDiscount);

            if (withDiscount == 'Y')
            {
                cout << "Discount: ";
                cin >> discount;
                total = total - discount;
                cout << "GRAND TOTAL: " << roundf(total * 100 / 100) << endl << endl;
            }
        }

    } while (decision == 'Y');

        return 0;
}
 
C++:
#include <iostream>
using namespace std;

int main()
{
    string itemName;
    float price;
    int quantity;
    float subtotal=0, total=0, discount=0;
    char decision, withDiscount;

    do {


        cout << endl << "Item name: ";
        cin >> itemName;
        cout << "Enter price : ";
        cin >> price;
        cout << "Enter quantity: ";
        cin >> quantity;
        cout << "__________________ " << endl;
        subtotal = price * quantity;
       
        printf("Total: %.2f\n", subtotal);
        total = total + subtotal;
   
        printf("GRAND TOTAL: %.2f\n\n", total);
       
       
        cout << "Add another item? Y/N: ";
        cin >> decision;
        decision = toupper(decision);

        if (decision != 'Y')
        {
            cout << "With discount? Y/N: ";
            cin >> withDiscount;
            withDiscount = toupper(withDiscount);

            if (withDiscount == 'Y')
            {
                cout << "Discount: ";
                cin >> discount;
                total = total - discount;
                cout << "GRAND TOTAL: " << roundf(total * 100 / 100) << endl << endl;
            }
        }

    } while (decision == 'Y');

        return 0;
}
salamat lods
 
C++:
#include <iostream>
using namespace std;

int main()
{
    string itemName;
    float price;
    int quantity;
    float subtotal=0, total=0, discount=0;
    char decision, withDiscount;

    do {


        cout << endl << "Item name: ";
        cin >> itemName;
        cout << "Enter price : ";
        cin >> price;
        cout << "Enter quantity: ";
        cin >> quantity;
        cout << "__________________ " << endl;
        subtotal = price * quantity;
       
        printf("Total: %.2f\n", subtotal);
        total = total + subtotal;
   
        printf("GRAND TOTAL: %.2f\n\n", total);
       
       
        cout << "Add another item? Y/N: ";
        cin >> decision;
        decision = toupper(decision);

        if (decision != 'Y')
        {
            cout << "With discount? Y/N: ";
            cin >> withDiscount;
            withDiscount = toupper(withDiscount);

            if (withDiscount == 'Y')
            {
                cout << "Discount: ";
                cin >> discount;
                total = total - discount;
                cout << "GRAND TOTAL: " << roundf(total * 100 / 100) << endl << endl;
            }
        }

    } while (decision == 'Y');

        return 0;
}
lodi bka pwd patulong

IMG20220521131411.webp IMG20220521131400.webp IMG20220521131421.webp IMG20220521131314.webp IMG20220521131346.webp IMG20220521131327.webp
 
Formula
Area of rectangle: length * width
Area of square: side * side
Area of triangle: base * height / 2
Area of circle: Pi*radius*radius
 
Kapag else ginamit mo, sa line 41, wala na dapat condition.
Since may condition, tingin ko dapat else if yung nasa line 41

Paki try palitan yung else ng else if.
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 10
    Replies
  • 1K
    Views
  • 2
    Participants
Last reply from:
Aoshinomori

Trending Topics

Online now

Members online
1,162
Guests online
4,612
Total visitors
5,774

Forum statistics

Threads
2,325,989
Posts
29,225,837
Members
1,167,757
Latest member
Hyperskill29
Back
Top