Ask 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 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."

+1
Answers (1)
  1. 23 January, 22:52
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers