Looping Problems

I have built a concert ticket purchase screen for my beginners class. The code itself is working fine, but I have to make the program loop if the user indicates they want to make more than one transaction and that is where my problem is coming in. I have read and re read the material in the book and I cannot get it. Please help. Thanks in advance!

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
cout << "Concert Ticket Purchase Page \n";

//data declaration section

int numberOfTransactions;
char ticketType;
double transactionTotal;
int numberTicketsPurchased;
int maxTransactions;

numberOfTransactions = 0;
do{
numberOfTransactions = numberOfTransactions + 1;
}while (numberOfTransactions <= 6);

cout << "Enter Total Number of Transactions: ";
cin >> numberOfTransactions;

cout << "There are 3 Ticket Types Available: \n";
cout << "F = Front Row, M = Middle Row, B = Back Row \n";

cout << "Please Enter the Ticket Type for this Transaction: \n";
cin >> ticketType;

if (ticketType == 'f'|| ticketType == 'F')
{
cout << "Ticket Type Purchased is Front Row! \n";
}
else if (ticketType == 'm' ||ticketType == 'M')
{
cout << "Ticket Type Purchased is Middle Row! \n";
}
else if (ticketType == 'b' || ticketType == 'B')
{
cout << "Ticket Type Purchased is Back Row! \n";
}

cout << "Please Enter the Number of Tickets for this Transaction: \n";
cin >> numberTicketsPurchased;

if (numberTicketsPurchased <= 9 && ticketType == 'f' || ticketType == 'F')
transactionTotal = 25.00 * numberTicketsPurchased;
else if (numberTicketsPurchased >= 10 && ticketType == 'f' || ticketType == 'F')
transactionTotal = 20.00 * numberTicketsPurchased;
else if (numberTicketsPurchased <= 9 && ticketType == 'm' || ticketType == 'M')
transactionTotal = 10.00 * numberTicketsPurchased;
else if (numberTicketsPurchased >= 10 && ticketType == 'm' || ticketType == 'M')
transactionTotal = 8.00 * numberTicketsPurchased;
else if (numberTicketsPurchased <= 9 && ticketType == 'b' || ticketType == 'B')
transactionTotal = 5.00 * numberTicketsPurchased;
else if (numberTicketsPurchased >= 10 && ticketType == 'b' || ticketType == 'B')
transactionTotal = 4.00 * numberTicketsPurchased;

cout << "The total for this Transaction is $ " << setw(5) << fixed << setprecision(2) << transactionTotal <<endl;


return 0;
}
Use a while(bool) loop around the code you want to repeat, and change the bool depending on whether they want to loop or not.
Topic archived. No new replies allowed.