Ask Question
23 August, 19:30

n this lab, you complete a partially prewritten C+ + program that includes functions with no parameters. The program asks the user if he or she has preregistered for tickets to an art show. If the user has preregistered, the program should call a function named discount () that displays the message, "You are preregistered and qualify for a 5 percent discount." If the user has not preregistered, the program should call a function named noDiscount () that displays the message, "Sorry, you did not preregister and do not qualify for a 5 percent discount."

+2
Answers (1)
  1. 23 August, 21:42
    0
    Answer: The c+ + program given below shows the usage of functions without parameters.

    #include

    using namespace std;

    / / functions are declared

    void discount ();

    void noDiscount ();

    int main () {

    char reply;

    cout<<"Welcome " <
    cout<<"Enter y if you have preregistered for tickets to an art show. Enter n if you have not preregistered for tickets to an art show. "<
    cin>>reply;

    if (reply = = 'y')

    / / function is called

    discount ();

    else

    / / function is called

    noDiscount ();

    }

    / / functions are defined

    void discount ()

    {

    cout<
    }

    void noDiscount ()

    {

    cout<
    }

    Explanation:

    Functions without parameters are used in the above program to display the message.

    First, functions are declared with void keyword since they do not return any value. Also, no parameters are passed into the functions.

    void discount ();

    void noDiscount ();

    Function or method declaration is done before main mandatorily.

    These functions can be defined anywhere, before or after main. The function definition contains message to display within scope of the function, i. e., {}.

    void discount ()

    {

    cout<
    }

    Next, a character variable is declared. This variable holds the input from the user.

    The user is asked to input the response either using y or n. Therefore, character variable is taken instead of a string variable.

    Based on the input from the user, the required function is called. The function is called simply by using the function name followed by semi-colon.

    discount ();

    Function declaration, definition and when the function is called, no parameters are passed or mentioned.

    The above program does not implements any class since it is not mentioned in the question.

    Also, the original partial program was not available for modification hence, this program has been done based on the requirements.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “n this lab, you complete a partially prewritten C+ + program that includes functions with no parameters. The program asks the user if he or ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers