ManiPalani
asked on
2 Nested Loops, the outer loop a while loop, AND a Switch
Mikes shoe shop sells shoes in 4 categories - A, B, C, D.
A costs $100/pair, Bcosts $150/pair, C-$200/Pair, D$300/pair.
You have to write a programme that calculates the total amount due by a customer when the number of pairs and the diferrent categories are specified.. The categories are indicated by the character A/B/C/D.. Finally the total number of pairs sold during the day must be displayed.
The program should display a prompting message asking for thenumber of pairs of shoes the customer wants to buy and should initialize the amount that is due to be paid to 0.Then it should have a 'for' loop going from 1 to the number of pairs the customer wants.
Inside the loop, the category of a specific pair is input. Then a switch statement should be used to determine the price.
You need not validate the input, but include a default case to display an appropriate message if an invalid category has been entered.
Add the price to the total that is due. When the loop ends, display the total amountthat is due by the customer.
The program should repeat the above for all customers until 0 is entered for the number of pairs of shoes.Finally the total number of pairs of shoes that has been sold should be displayed.
Program needs 2 nested loops. The outer loop will be a while loop.
A costs $100/pair, Bcosts $150/pair, C-$200/Pair, D$300/pair.
You have to write a programme that calculates the total amount due by a customer when the number of pairs and the diferrent categories are specified.. The categories are indicated by the character A/B/C/D.. Finally the total number of pairs sold during the day must be displayed.
The program should display a prompting message asking for thenumber of pairs of shoes the customer wants to buy and should initialize the amount that is due to be paid to 0.Then it should have a 'for' loop going from 1 to the number of pairs the customer wants.
Inside the loop, the category of a specific pair is input. Then a switch statement should be used to determine the price.
You need not validate the input, but include a default case to display an appropriate message if an invalid category has been entered.
Add the price to the total that is due. When the loop ends, display the total amountthat is due by the customer.
The program should repeat the above for all customers until 0 is entered for the number of pairs of shoes.Finally the total number of pairs of shoes that has been sold should be displayed.
Program needs 2 nested loops. The outer loop will be a while loop.
Post some code.
ASKER
Could rstaveley please refund the 500 points as I am planning to hold this question until I add some code.
The accept button was pressed in error.
ManiPalani
The accept button was pressed in error.
ManiPalani
Post a request in http:/Community_Support/ with a link to this question (which you can paste in as http:/Q_21805246.html) and they'll reopen the question and restore points. I'm not an administrator and cannot do this for you - otherwise I'd be happy to.
ASKER
Question on Hold till Mani Palani posts some code. (I dont know how to cancel this question till then)
ASKER
Question reopened
Can someone give me a clue as to how to :
1. Subtotal the values for each customer ie TotalPrice
2. Total the total number of shoes for all customers ie NumberPairs
#include <iostream>
#include <string>
using namespace std;
int main () {
char Category;
int counter, NumberPairs, PriceA, PriceB, PriceC, PriceD, TotalPrice;
do {
cout << " HOW MANY PAIRS OF SHOES? ";
cin >> NumberPairs;
for (counter = 1; counter <=NumberPairs; counter++)
{
cout << " Enter category :" <<endl;
cin >> Category;
switch (Category) {
case 'A':
PriceA = 100;
cout << 100 << endl;
break;
case 'B':
PriceB = 150;
cout << 150 << endl;
break;
case 'C':
PriceC = 200;
cout << 200 << endl;
break;
case 'D':
PriceD = 300;
cout << 300 << endl;
break;
default:
cout << " Invalid Category" << endl;
} //end switch
} //end for
} //end do
while ( NumberPairs!=0);
return 0;
}//END INT MAIN
Can someone give me a clue as to how to :
1. Subtotal the values for each customer ie TotalPrice
2. Total the total number of shoes for all customers ie NumberPairs
#include <iostream>
#include <string>
using namespace std;
int main () {
char Category;
int counter, NumberPairs, PriceA, PriceB, PriceC, PriceD, TotalPrice;
do {
cout << " HOW MANY PAIRS OF SHOES? ";
cin >> NumberPairs;
for (counter = 1; counter <=NumberPairs; counter++)
{
cout << " Enter category :" <<endl;
cin >> Category;
switch (Category) {
case 'A':
PriceA = 100;
cout << 100 << endl;
break;
case 'B':
PriceB = 150;
cout << 150 << endl;
break;
case 'C':
PriceC = 200;
cout << 200 << endl;
break;
case 'D':
PriceD = 300;
cout << 300 << endl;
break;
default:
cout << " Invalid Category" << endl;
} //end switch
} //end for
} //end do
while ( NumberPairs!=0);
return 0;
}//END INT MAIN
ASKER
Problem solved!
ASKER
I am not sure how to delete this question from the list of open questions. Can an adminstrator help me?
ASKER
Thank you for the reply but I cannot find the link above the text box referred to in the help file.
Then post a request in http:/Community_Support/ with a link to this question (which you can paste in as http:/Q_21805246.html), pointing out that there is a problem with the EE software, causing the link not to be displayed. It could be a consequence of reopening the question.
Beware that you cannot delete a question yourself when others have posted comments to it - see http:/help.jsp#hi302 - you'll need to ask the moderator to delete the question for you.
Fine by me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
We can help you, but you've got to get the ball rolling, ManiPalani. Show us what's snagging you and we may be able to help, but we can't do the assignment for you.