Dieser Code wurde entwickelt, um den endgültigen Preis eines Artikels basierend auf der Kundenmenge zu ermitteln. Ich habe bereits in den Gleichungen hinzugefügt, aber wenn es ausgeführt wird, werden der Rabatt und der Endpreis nicht richtig ausgewertet. Wenn jemand weiß, wo ich im Pseudocode falsch gelaufen bin, wäre das sehr hilfreich.Rabattcode .. Wo bin ich falsch gelaufen?
using namespace std;
int main() {
// Variables
double Retail, quantity, discount1, discount2, discount3, discount4, TotalCost1, TotalCost2, TotalCost3, TotalCost4;
Retail = 99;
quantity = 0;
discount1 = (quantity * Retail) * .20;
discount2 = (quantity * Retail) * .30;
discount3 = (quantity * Retail) * .40;
discount4 = (quantity * Retail) * .50;
TotalCost1 = quantity - discount1;
TotalCost2 = quantity - discount2;
TotalCost3 = quantity - discount3;
TotalCost4 = quantity - discount4;
//Equations
cout << "Please enter the quantity of items you would like to purchase: " << endl;
cin >> quantity;
cout << "The number of items being purchased is: " << quantity << endl;
if (quantity <= 19) {
cout << "Your final price is: " << discount1 << endl;
}
if (quantity >= 20) {
cout << "Your final price is: " << discount2 << endl;
}
if (quantity >= 50) {
cout << "Your final price is: " << discount3 << endl;
}
if (quantity >= 100) {
cout << "Your final price is: " << discount4 << endl;
}
system("pause");
}
Bitte seien Sie spezifischer über Sie, was bedeutet "es läuft nicht richtig." Sehen Sie sich auch [mcve] an. Sie haben den Code, Sie müssen nur detaillierter zu dem spezifischen Problem sein, dem Sie gegenüberstehen. – Lexi
Post echten Code und die spezifischen Fehler, die Sie bekommen. –
Was ist 'if (Menge <= 19, Rabatt1)' für? – doctorlove