Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

2 Nested Loops, the outer loop a while loop, AND a Switch

Posted on 2006-04-07
16
Medium Priority
?
423 Views
Last Modified: 2010-04-01
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.
0
Comment
Question by:ManiPalani
14 Comments
 
LVL 17

Expert Comment

by:rstaveley
ID: 16398866
This is homework. See http:/help.jsp#hi56

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.
0
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16399459
Post some code.
0
 

Author Comment

by:ManiPalani
ID: 16401954
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:rstaveley
ID: 16405108
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.
0
 

Author Comment

by:ManiPalani
ID: 16406410
Question on Hold till Mani Palani posts some code. (I dont know how to cancel this question till then)
0
 

Author Comment

by:ManiPalani
ID: 16483490
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
0
 

Author Comment

by:ManiPalani
ID: 16484386
Problem solved!
0
 

Author Comment

by:ManiPalani
ID: 16484394
I am not sure how to delete this question from the list of open questions. Can an adminstrator help me?
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 16485404
0
 

Author Comment

by:ManiPalani
ID: 16485700
Thank you for the reply but I cannot find the link above the text box referred to in the help file.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 16485777
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.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 16485813
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.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 16491764
Fine by me.
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16518667
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question