What's new

C & C++ Pahelp

plasmadash

Established
Joined
May 19, 2016
Posts
32
Reaction
9
pahelp naman po sa pag gawa ng cashier program with subtotal, discount and grandtotal.. salamat po
 

plasmadash

Established
May instructions TS?
ganyan ung dapat ung magiging program lods!!!

Capture.JPG
 

Attachments

Aoshinomori

Journeyman
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;
}
 

plasmadash

Established
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
 

plasmadash

Established
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.jpg IMG20220521131400.jpg IMG20220521131421.jpg IMG20220521131314.jpg IMG20220521131346.jpg IMG20220521131327.jpg
 

Attachments

Aoshinomori

Journeyman
Formula
Area of rectangle: length * width
Area of square: side * side
Area of triangle: base * height / 2
Area of circle: Pi*radius*radius
 

Aoshinomori

Journeyman
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.
 
Last edited:
Top