LAB 6.2 Introduction to Pass by Value Retrieve program newproverb.cpp from the Lab 6.1 folder. The code is as follows: // This program will allow the user to input from the keyboard // whether the last word to the following proverb should be party or country: // "Now is the time for all good men to come to the aid of their ___" // Inputting a 1 will use the word party. Any other number will use the word country.   // PLACE YOUR NAME HERE   #include #include using namespace std;   // Fill in the prototype of the function writeProverb.   int main() { int wordCode;   cout << "Given the phrase:" << endl; cout << "Now is the time for all good men to come to the aid of their ___" << endl;   cout << "Input a 1 if you want the sentence to be finished with party" << endl; cout << "Input any other number for the word country" << endl;   cout << "Please input your choice now" << endl; cin >> wordCode;  cout << endl;   writeProverb(wordCode);   return 0; }   // ****************************************************************************** // writeProverb // // task:   This function prints a proverb. The function takes a number //           from the call. If that number is a 1 it prints "Now is the time //           for all good men to come to the aid of their party." //           Otherwise, it prints "Now is the time for all good men //           to come to the aid of their country." // data in:  code for ending word of proverb (integer) // data out: no actual parameter altered // // *****************************************************************************   void writeProverb(int number) { // Fill in the body of the function to accomplish what is described above }   Exercise 1: Some people know this proverb as “Now is the time for all good men to come to the aid of their country” while others heard it as “Now is the time for all good men to come to the aid of their party.” This program will allow the user to choose which way they want it printed. Fill in the blanks of the program to accomplish what is described in the program comments. What happens if you inadvertently enter a float such as -3.97? Exercise 2: Change the program so that an input of 1 from the user will print “party” at the end, a 2 will print “country” and any other number will be invalid so that the user will need to enter a new choice. sample run: Given the phrase: Now is the time for all good men to come to the aid of their___ input a 1 if you want the sentence to be finished with party input a 2 if you want the sentence to be finished with county please input your choice now 4 i'm sorry but that is an incorrect choice; Please input a 1 or 2 2 Now is the time for all good men to come to the aid of their country Exercise 3: Change the previous program so the user may input the word to end the phrase. The string holding the user’s input word will be passed to the proverb function instead of passing a number to it. Notice that this change requires you to change the proverb function heading and the prototype as well as the call to the function. Sample Run: Given the phrase: Now is the time for all good men to come to the aid of their Please input the word you would like to have finish the proverb family Now is the time for all good men to come to the aid of their family

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

LAB 6.2 Introduction to Pass by Value

Retrieve program newproverb.cpp from the Lab 6.1 folder. The code is as follows:

// This program will allow the user to input from the keyboard

// whether the last word to the following proverb should be party or country:

// "Now is the time for all good men to come to the aid of their ___"

// Inputting a 1 will use the word party. Any other number will use the word country.

 

// PLACE YOUR NAME HERE

 

#include <iostream>

#include <string>

using namespace std;

 

// Fill in the prototype of the function writeProverb.

 

int main()

{

int wordCode;

 

cout << "Given the phrase:" << endl;

cout << "Now is the time for all good men to come to the aid of their ___"

<< endl;

 

cout << "Input a 1 if you want the sentence to be finished with party"

<< endl;

cout << "Input any other number for the word country" << endl;

 

cout << "Please input your choice now" << endl;

cin >> wordCode; 

cout << endl;

 

writeProverb(wordCode);

 

return 0;

}

 

// ******************************************************************************

// writeProverb

//

// task:   This function prints a proverb. The function takes a number

//           from the call. If that number is a 1 it prints "Now is the time

//           for all good men to come to the aid of their party."

//           Otherwise, it prints "Now is the time for all good men

//           to come to the aid of their country."

// data in:  code for ending word of proverb (integer)

// data out: no actual parameter altered

//

// *****************************************************************************

 

void writeProverb(int number)

{

// Fill in the body of the function to accomplish what is described above

}

 

Exercise 1: Some people know this proverb as “Now is the time for all good
men to come to the aid of their country” while others heard it as “Now is
the time for all good men to come to the aid of their party.” This program
will allow the user to choose which way they want it printed. Fill in the
blanks of the program to accomplish what is described in the program
comments. What happens if you inadvertently enter a float such as -3.97?


Exercise 2: Change the program so that an input of 1 from the user will print
“party” at the end, a 2 will print “country” and any other number will be
invalid so that the user will need to enter a new choice.

sample run:

Given the phrase:

Now is the time for all good men to come to the aid of their___

input a 1 if you want the sentence to be finished with party

input a 2 if you want the sentence to be finished with county

please input your choice now

4

i'm sorry but that is an incorrect choice; Please input a 1 or 2

2

Now is the time for all good men to come to the aid of their country

Exercise 3: Change the previous program so the user may input the word to
end the phrase. The string holding the user’s input word will be passed to the
proverb function instead of passing a number to it. Notice that this change
requires you to change the proverb function heading and the prototype as
well as the call to the function.

Sample Run:
Given the phrase:
Now is the time for all good men to come to the aid of their
Please input the word you would like to have finish the proverb
family
Now is the time for all good men to come to the aid of their family

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Types of Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education