Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:36:02+00:00 2026-06-12T13:36:02+00:00

I need to make ConfirmChoice cancel from the main function before it starts the

  • 0

I need to makeConfirmChoice cancel from the main function before it starts the rest of the code. I have tried a lot and can not figure this out.

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

const char CASH = 'C';
const char CREDIT = 'D';
const char NOSEBLEED = 'N';
const char BOX_SEAT = 'B';
const char FIFTY_YARD_LINE = 'F';
const char STUDENT_SECTION = 'S';
const float NOSEBLEED_PRICE = 43.42;
const float BOX_SEAT_PRICE = 353.85;
const float FIFTY_YARD_LINE_PRICE = 94.05;
const float STUDENT_SECTION_PRICE = 19.99;

//---------------------------------------------------------------
// Function: ConfirmChoice
// Purpose:  Confirms the users ticket purchase before processing payment
// Parameters:  TicketType - The type of ticket selected
// Returns:  true if the user confirms the selection, false otherwise
//--------------------------------------------------------------
bool ConfirmChoice(const char TicketType)
{
   char Choice;
   bool Confirmed;

   // Print out their selection
   cout << "\nYou have chosen to purchase ";
   cout << fixed << setprecision(2);
   switch (TicketType)
   {
   case NOSEBLEED:
      cout << "Nosebleed ticket(s) at a price of $";
      cout << NOSEBLEED_PRICE << ".\n";
      break;
   case BOX_SEAT:
      cout << "Box Seat ticket(s) at a price of $";
      cout << BOX_SEAT_PRICE << ".\n";
      break;
   case FIFTY_YARD_LINE:
      cout << "Ticket(s) on the 50 yard line at a price of $";
      cout << FIFTY_YARD_LINE_PRICE << ".\n";
      break;
   case STUDENT_SECTION:
      cout << "Ticket(s) in the Student Section at a price of $";
      cout << STUDENT_SECTION_PRICE << ".\n";
      break;
   }

   // Confirm the selection
   cout << "Do you wish to confirm your purchase? Enter Y or N: ";
   cin >> Choice;
   Choice = toupper(Choice);
   while (Choice != 'Y' && Choice != 'N')
   {
      cout << "Invalid selection.  Please enter either Y or N: ";
      cin >> Choice;
      Choice = toupper(Choice);
   }
   Confirmed = (Choice == 'Y');

   // Check confirmation        
   if (Confirmed)
      cout << "You have confirmed your choice.\n" << endl;
   else
      cout << "You not confirmed your choice.\n" << endl;
   return (Confirmed);
}

//-------------------------------------------
// Function: CalculateChange
// Purpose:  To output the change due
// Parameters:  ChangeDue - The amount of change needed 
// Returns:  Nothing
//-------------------------------------------
void CalculateChange(const float ChangeDue)
{
   int Change = 0;
   int Dollars = 0;
   int Quarters = 0;
   int Dimes = 0;
   int Nickels = 0;
   int Pennies = 0;

   // Compute change  
   Change = ChangeDue * 100;
   Dollars = Change / 100;
   Change = Change % 100;
   Quarters = Change / 25;
   Change = Change % 25;
   Dimes = Change / 10;
   Change = Change % 10;
   Nickels = Change / 5;
   Pennies = Change % 5;

   // Print out change
   cout << "Your change is \n\t";
   cout << Dollars << " Dollars\n\t";
   cout << Quarters << " Quarters\n\t";
   cout << Dimes << " Dimes\n\t";
   cout << Nickels << " Nickels\n\t";
   cout << Pennies << " Pennies\n";
}

 int main()
{   
   // Prints my name and UAID
        cout <<"\n\nName: Ivory Newbern\n";
        cout << "UAID: 010563918\n";

   // Declarations 

   char TChoice ;       // Ticket type: Nosebleed, box seats etc.. 
   char PChoice = GetPaymentType();     // Payment choice: cash or credit card
   bool Confirmed ;     // Did the user confirm the selection
   float Cost ;         // The cost of the ticket puchased
   float ChangeDue;     // The amount of change owed (for cash purchases)



   // Get the choice of payment type
    PChoice;

   // Get the choice of ticket type
    GetTicketType( TChoice);
   // Confirm the selection
    ConfirmChoice( TChoice);

    // If they confirm the purchase


      // Calls functions to figure out the price of ticket purchase(s) 

           if (TChoice == BOX_SEAT)
               Cost = CalculateCost(BOX_SEAT_PRICE);
           if (TChoice == NOSEBLEED)
               Cost = CalculateCost(NOSEBLEED_PRICE);
           if (TChoice == STUDENT_SECTION)
               Cost = CalculateCost(STUDENT_SECTION_PRICE);
           if (TChoice == FIFTY_YARD_LINE)
               Cost = CalculateCost(FIFTY_YARD_LINE_PRICE);

      // Handles the payment 

           if( PChoice == 'C');
                PayWithCash(Cost,ChangeDue) , CalculateChange(ChangeDue);
           if( PChoice == 'D')
                PayWithCredit(Cost);

       // Say goodbye to the customer
           if (TChoice == BOX_SEAT)
           cout << "Thank you for the purchase of your 'BOX_SEAT' tickets ,have a nice day!" << endl;
           if (TChoice == NOSEBLEED)
              cout << "Thank you for the purchase of your 'NOSEBLEED' tickets ,have a nice day!" << endl; 
           if (TChoice == STUDENT_SECTION)
              cout << "Thank you for the purchase of your 'STUDENT_SECTION' tickets ,have a nice day!" << endl;
           if (TChoice == FIFTY_YARD_LINE)
                cout << "Thank you for the purchase of your 'FIFTY_YARD_LINE' tickets ,have a nice day!" << endl;


   // Else

      // Cancel the purchase 
    system ("PAUSE");
   return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:36:03+00:00Added an answer on June 12, 2026 at 1:36 pm

    like this:

    if( ConfirmChoice( TChoice));
    
           {
    
                   if (TChoice == BOX_SEAT)
                       Cost = CalculateCost(BOX_SEAT_PRICE);
                   if (TChoice == NOSEBLEED)
                       Cost = CalculateCost(NOSEBLEED_PRICE);
                   if (TChoice == STUDENT_SECTION)
                       Cost = CalculateCost(STUDENT_SECTION_PRICE);
                   if (TChoice == FIFTY_YARD_LINE)
                       Cost = CalculateCost(FIFTY_YARD_LINE_PRICE);
    
              // Handles the payment 
    
                   if( PChoice == 'C');
                        PayWithCash(Cost,ChangeDue) , CalculateChange(ChangeDue);
                   if( PChoice == 'D')
                        PayWithCredit(Cost);
    
               // Say goodbye to the customer
                   if (TChoice == BOX_SEAT)
                   cout << "Thank you for the purchase of your 'BOX_SEAT' tickets ,have a nice day!" << endl;
                   if (TChoice == NOSEBLEED)
                      cout << "Thank you for the purchase of your 'NOSEBLEED' tickets ,have a nice day!" << endl; 
                   if (TChoice == STUDENT_SECTION)
                      cout << "Thank you for the purchase of your 'STUDENT_SECTION' tickets ,have a nice day!" << endl;
                   if (TChoice == FIFTY_YARD_LINE)
                        cout << "Thank you for the purchase of your 'FIFTY_YARD_LINE' tickets ,have a nice day!" << endl;
    
        }
          else
        {
            system ("PAUSE");
           return 0;
        }<br/>
    

    for optimized purpose:
    here else part not required, u can simply remove the else part,like this:

    if( ConfirmChoice( TChoice));
    
               {
    
                       if (TChoice == BOX_SEAT)
                           Cost = CalculateCost(BOX_SEAT_PRICE);
                       if (TChoice == NOSEBLEED)
                           Cost = CalculateCost(NOSEBLEED_PRICE);
                       if (TChoice == STUDENT_SECTION)
                           Cost = CalculateCost(STUDENT_SECTION_PRICE);
                       if (TChoice == FIFTY_YARD_LINE)
                           Cost = CalculateCost(FIFTY_YARD_LINE_PRICE);
    
                  // Handles the payment 
    
                       if( PChoice == 'C');
                            PayWithCash(Cost,ChangeDue) , CalculateChange(ChangeDue);
                       if( PChoice == 'D')
                            PayWithCredit(Cost);
    
                   // Say goodbye to the customer
                       if (TChoice == BOX_SEAT)
                       cout << "Thank you for the purchase of your 'BOX_SEAT' tickets ,have a nice day!" << endl;
                       if (TChoice == NOSEBLEED)
                          cout << "Thank you for the purchase of your 'NOSEBLEED' tickets ,have a nice day!" << endl; 
                       if (TChoice == STUDENT_SECTION)
                          cout << "Thank you for the purchase of your 'STUDENT_SECTION' tickets ,have a nice day!" << endl;
                       if (TChoice == FIFTY_YARD_LINE)
                            cout << "Thank you for the purchase of your 'FIFTY_YARD_LINE' tickets ,have a nice day!" << endl;
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some part of asynchronous code in my handlers, I need make this
I need make UIAlertView blocking. Because i have function and i need to return
I need make some action (dump statistical data) before the Dart program ends. The
I need to make a series (1-20) ajax calls and I need to have
I need make a merge sort using an additional array. Here is my code:
Need to make a function that would open a popout with a div inheriting
I need make system call from method of Ruby of Rails , but I
i have problem with enum I need make a enum in base class or
I need to make a few tweaks to only the following elements from jquery.ui.autocomplete.css
there have two value, $a and $b . I need make a judge, $a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.