how would i write nested for loops for this program?
there are 3 products. product 1 is $12.50, product 2 is $8.90 and product 3 is $20.10. write a C++ program that reads the product number and the quantity sold per day, and then calculates and display the total retail value for this product sold at the end of the week. the program shud also calculate and display the total retail value of all products sold at the end of the week. use a switch statement and nested for loops.
this is wat i got so far.
#include <iostream>
using namespace std;
int main( )
{
const int NrOfProducts = 3;
const int NrOfDays = 7;
int proNr, quantity;
float price, totAll = 0.0, totWeek = 0.0;
for (int i = 0; i < 3; i++)
{
cout << "Enter the product number: ";
cin >> proNr;
while (proNr > 3)
{
cout <<"Invalid product number. Enter a product number: ";
cin >> proNr;
}
for (int j=1; j<8; j++)
{
cout << "Enter the quantity sold for ";
if (j == 1)
cout << "Monday: ";
else if (j == 2)
cout << "Tuesday:";
else if (j == 3)
cout << "Wednesday:";
else if (j == 4)
cout << "Thursday:";
else if (j == 5)
cout << "Friday:";
else if (j == 6)
cout << "Saturday:";
else
cout << "Sunday:";
cin >> quantity;
}
switch (proNr)
{
case 1:
price = 12.50;
break;
case 2:
price = 8.90;
break;
case 3:
price = 20.10;
}
for (int k=0; k<8; k++)
{
totWeek = 0.0;
quantity++;
price *= quantity;
totWeek += price;
}
cout << "The total retail value of this product sold for this week is R"
<< totWeek << endl;
for (int l=0; l<8; l++)
{
totWeek = 0.0;
quantity++;
price *= quantity;
totWeek += price;
}
}
cout << endl;
return 0;
}