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
#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 lodsC++:#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 patulongC++:#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; }
yan nagiging prob lodi, nageerrorFormula
Area of rectangle: length * width
Area of square: side * side
Area of triangle: base * height / 2
Area of circle: Pi*radius*radius
ganyan nagiging outputKapag 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.