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

  • Home
  • SEARCH
  • 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 8646351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:47:05+00:00 2026-06-12T12:47:05+00:00

In my program I am trying to call the void function from Main but

  • 0

In my program I am trying to call the void function from Main but I can’t figure out the correct way.

Main is at the very bottom and void GetTicketType(char &Choice) is the function I need to call to cout the ticket type.

//---------------------------------------------------------------------------
// Purpose: This program simulates a ticket office for sporting events
// Author: TBA
// Date: TBA
//---------------------------------------------------------------------------
#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";
}

//---------------------------------------------------------------------------
// Function: CalculateCost
// Purpose: Calculate the cost of the ticket purchase(s) (num_tickets * price_per_ticket)
// Parameters: PricePerTicket - Ticket price based on the type of ticket
// Returns: The cost of purchasing the chosen number of tickets 
//---------------------------------------------------------------------------
float CalculateCost(const float PricePerTicket)
{
int TicketCount;
float Cost;

cout << "How many tickets would you like? Please enter a positive integer value: ";
cin >> TicketCount;
while (TicketCount < 0)
{
cout << "Invalid entry. Please re-enter: ";
cin >> TicketCount;
}

Cost = PricePerTicket * TicketCount;
cout << "Your bill is: $" << fixed << setprecision(2) << Cost << endl;
return Cost;
}

//---------------------------------------------------------------------------
// Function: GetPaymentType
// Purpose: Ask the user how they want to pay, cash or credit
// Parameters: None
// Returns: Value is CREDIT or CASH (global character constants) 
//---------------------------------------------------------------------------
char GetPaymentType()
{
char Choice;

// Print the main menu describing the ticket payment types 
cout << "+-------------------------------------------------------+\n";
cout << "+ Welcome to our Ticket Office +\n";
cout << "+-------------------------------------------------------+\n";
cout << endl << endl;

// Cash or credit card (in upper case)
cout << "How would you like to pay?\n";
cout << "Enter C for cash or D for credit card: ";
cin >> Choice;
Choice = toupper(Choice);
while (Choice != CASH && Choice != CREDIT)
{
cout << "Invalid choice. Please enter C for cash or D for credit card: ";
cin >> Choice;
Choice = toupper(Choice);
}
return Choice;
}

//---------------------------------------------------------------------------
// Function: GetTicketType
// Purpose: Get the customer's choice between 4 types of tickets
// Parameters: Choice - Set to the user's choice
// Returns: Nothing
//---------------------------------------------------------------------------
void GetTicketType(char &Choice)
{
// Ask the customer what type of ticket s/he prefers to buy 
cout << "\nWhat type of ticket would you like?\n";
cout << "\t" << NOSEBLEED << " for Nosebleed Section, Price = $";
cout << NOSEBLEED_PRICE << endl;
cout << "\t" << BOX_SEAT << " for Box Seats, Price = $";
cout << BOX_SEAT_PRICE << endl;
cout << "\t" << FIFTY_YARD_LINE << " for Seats on the Fifty Yard Line, Price = $";
cout << FIFTY_YARD_LINE_PRICE << endl;
cout << "\t" << STUDENT_SECTION << " for Student Section, Price = $";
cout << STUDENT_SECTION_PRICE << endl;

// Get ticket choice (in upper case)
cout << "Enter choice: ";
cin >> Choice;
Choice = toupper(Choice);   
while (Choice != NOSEBLEED && Choice != BOX_SEAT && 
Choice != FIFTY_YARD_LINE && Choice != STUDENT_SECTION)
{
cout << "Invalid choice. Please re-enter: ";
cin >> Choice;
Choice = toupper(Choice);
}
}

//---------------------------------------------------------------------------
// Function: PayWithCash
// Purpose: Handles payment by cash. Asks the user for the money until
// they enter enough, then updates the ChangeDue parameter
// Parameters: Cost - The amount due for the purchase
// ChangeDue - The amount of change due to customer
// Returns: Nothing
//---------------------------------------------------------------------------
void PayWithCash(const float Cost, float &ChangeDue)
{
float CashOffered;

// Pay in cash
cout << "Please enter enough cash. Your bill is $" << Cost << ": $ ";
cin >> CashOffered;

// Check sufficiency
while (CashOffered < Cost)
{
cout << "That is not enough to pay for your purchase!\n"
<< " Please enter at least $" << Cost << ": ";
cin >> CashOffered;
}

// Calculate change
ChangeDue = CashOffered - Cost;
}

//---------------------------------------------------------------------------
// Function: PayWithCredit
// Purpose: Handles payment by credit. Basically, just prints a statement
// telling them that their card will be charged.
// Parameters: const float Cost - the amount due for the purchase
// Returns: Nothing
//---------------------------------------------------------------------------
void PayWithCredit(const float Cost)
{
cout << "Your credit card will be billed for $" << Cost << ".\n";
}

//---------------------------------------------------------------------------
// Function: main
// Purpose: This is the main program that calls functions above.
// Parameters: None
// Returns: Nothing
//---------------------------------------------------------------------------
int main()
{
// Declarations 

char TChoice ;   // Ticket type: Nosebleed, box seats etc.. 
TChoice << GetTicketType( &TChoice);
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)

// Print your name and UAID

// Get the choice of payment type

// Get the choice of ticket type
GetTicketType(TChoice );
{
cout << "You have chosen the " << TChoice << "tickets. " <<".\n";
}

// Confirm the selection

// If they confirm the purchase

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

// Be sure to use the named constants

// Handle the payment

// Say goodbye 

// Else

// Cancel the purchase 

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-12T12:47:07+00:00Added an answer on June 12, 2026 at 12:47 pm

    Change

    TChoice << GetTicketType( &TChoice);
    

    To Simple

    GetTicketType( &TChoice);
    

    Since TChoice << GetTicketType( &TChoice); is doing bitwise left shift operation it will expect an integer type after <<.Your function is returning nothing(void) and thus causes an error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call a java program from python using command line. The code
I have been trying to call a mapreduce job from a simple java program
I am trying to learn how to call this write_data(…) function from the funmain()
I'm trying to print call stack from within a program. Unfortunately, call to glibc
I have a program I'm trying to compile, lets call it P. P needs
I am trying to get the program to call up the current date, add
I'm trying to build a simple program to price call options using the black
Below is my program and I am trying to get the call stack when
I've been writing a program trying to find itself using the procps library. But
My program is trying to create an key on the HKLM\Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\ but instead

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.