12
daysales = daysales + (price - discount); weeksales = daysales + weeksales;
daysales = daysales + (price - discount); weeksales = weeksales + (price - discount);
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
#include <iostream> using namespace std; int main() { //declaration int daysinweek = 7; double daysales = 0; double weeksales= 0 ; double weight; double discountrate; double price; int productcode; for (int day = 1; day <= daysinweek; day++ ) { daysales = 0; cout << "Day" << day << endl; cout<<endl; do { //enter product name cout << "Enter Product Number: "; cin >> productcode; //loop while (productcode != 1001 && productcode != 1002 && productcode != 1003) { cout<<"Wrong , Please enter again : "; cin>> productcode; } //enter weight and price cout << "Weight: "; cin >> weight; cout << "price: "; cin >> price; if (productcode == 1001 && weight > 10) discount = price * 0.10; else if (productcode == 1001 && weight <= 10) discount = price * 0.05; else if (productcode == 1002 && weight > 10) discount = price * 0.07; else if (productcode == 1002 && weight <= 10) discount = price * 0.03; else if (productcode == 1003 && weight > 10) discount = price * 0.25; else if (productcode == 1003 && weight <= 10) discount = price * 0.10; daysales = daysales + (price - discount); weeksales = daysales + weeksales; //add product cout<<endl; char add = ' '; cout << "Add another item[y/n]: "; cin >> add; cout<<endl; if(add == 'y') { continue; } else { cout << "Daily sales is: RM" << daysales << endl; cout<<endl; break; } } while (1); } cout << "Weekly Sales is: RM" << weeksales<< endl; return 0; }