Design a menu with appropriate user interactions and checks for valid entry. Use C++ to successfully complete this criterion. Your simple program will need a menu that can validate user input and is easy to use. It needs to include options for the display of a multiplication table, doubling a value, and exiting the program. If either of the first two options are selected, then users need to be prompted to input a numeric value. The menu should be displayed using a loop, where

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
  • Design a menu with appropriate user interactions and checks for valid entry. Use C++ to successfully complete this criterion. Your simple program will need a menu that can validate user input and is easy to use. It needs to include options for the display of a multiplication table, doubling a value, and exiting the program. If either of the first two options are selected, then users need to be prompted to input a numeric value. The menu should be displayed using a loop, where the user can choose to exit the program only by selecting option 3. Any user input other than 1, 2, or 3 should result in an error message that returns the user to the menu. An example menu might look like the following:1: Display a Multiplication Table 2: Double a Value 3: Exit Enter your selection as a number 1, 2, or 3.
  • Create code that prints a multiplication table for a given numeric value. Both C++ and Python will be necessary to successfully complete this criteria. Be sure to focus on their interactions as you work. Consider the following steps to help organize your code design. Note that you should have already written C++ code that prompts a user to input a number while working on the menu portion of this assignment.
    • Write C++ code that reads and passes a number, as an integer, to Python. C++ should also call a function in Python to display the multiplication table for the passed parameter. Note that you will be creating that function in the next step. For this step, be sure to check the starter code you were given and use the applicable components.
    • Write Python code to create a multiplication table for the given integer. Name this function MultiplicationTable for consistency. The printed table should include values for the multipliers one through ten. An example result is shown below.

6 X 1 = 6 6 X 2 = 12 6 X 3 = 18 6 X 4 = 24 6 X 5 = 30 6 X 6 = 36 6 X 7 = 42 6 X 8 = 48 6 X 9 = 54 6 X 10 = 60

  • Create code that doubles a given numeric value. Both C++ and Python will be necessary to successfully complete this criteria. Be sure to focus on their interactions as you work. Consider the following steps to help organize your code design. Note that you should have already written C++ code that prompts a user to input a number while working on the menu portion of this assignment.
    • Once the number has been read from the user in C++, call the callIntFunc function. Then pass the Python function name (which you will create in the next step) and the value entered by the user as parameters to the callIntFunc function.
    • Write a Python function to receive the user input and then return that value multiplied by two. For consistency, name the function you create DoubleValue. Refer to the example in your starter code as you work, but remember the example is squaring the value (or multiplying the value by itself) rather than doubling it.
    • In C++, receive the value sent from the Python function (DoubleValue) and display the value on the screen.
  • Apply industry standard best practices such as in-line comments and appropriate naming conventions to enhance readability and maintainability. Remember that you must demonstrate industry standard best practices in all your code to ensure clarity, consistency, and efficiency. This includes the following:
    • Inputting validation and error handling to anticipate, detect, and respond to run-time and user errors (for example, make sure you have option 3 on your menu so users can exit the program)
    • Inserting in-line comments to denote your changes and briefly describe the functionality of the code
    • Using appropriate variable, parameter, and other naming conventions throughout your code

The C++ code that I have in the screenshot works exactly how it is supposed to. My issue is that I cannot get the Python integration right and I could really use some help with that piece of the problem.

 

n Explorer
0.
Solution Explorer (Ctrl+:)
olution '6-3 integrating languages christopher banner' (1
6-3 integrating languages christopher banner
■■References
External Dependencies
Header Files
Resource Files
Source Files
my_module.py
MI
> ++ Source.cpp
x my_module.py
Source.cpp X
6-3 integrating languages christopher banner
#include <iostream>
2
3
4
using namespace std;
5
6
7
Evoid Multitable()
8
{
9
int a;
10
cout << "Enter a number: ";
cin >> a;
11
12
8
for (int i= 1; i < 11; i++)
13
14
cout << a << " X " << i << * = * << (a * i) << "\n";
15
16
17
Evoid doubl()
18
{
19
int a;
20
cout << "Enter a number: ";
21
cin >> a;
22
cout << "Double of value: " << (2 * a) << "\n";
23
}
24
Evoid menu() {
25
int ch;
26
cout << "1: Display a Multiplication Table \n";
27
cout << "2: Double a Value \n";
28
cout << "3: Exit\n";
29
cout << "Enter your choice: \n";
cin >> ch;
30
switch (ch) {
31
32
33
case 1: {
Multitable();
34
menu();
break;
35
36
}
37
case 2: {
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-0-0
8
8
doubl();
menu();
break;
case 3: {
}
default:
cout << "Thank you\n";
break;
printf("Wrong Input\n");
int main()
{
menu();
return 0;
Transcribed Image Text:n Explorer 0. Solution Explorer (Ctrl+:) olution '6-3 integrating languages christopher banner' (1 6-3 integrating languages christopher banner ■■References External Dependencies Header Files Resource Files Source Files my_module.py MI > ++ Source.cpp x my_module.py Source.cpp X 6-3 integrating languages christopher banner #include <iostream> 2 3 4 using namespace std; 5 6 7 Evoid Multitable() 8 { 9 int a; 10 cout << "Enter a number: "; cin >> a; 11 12 8 for (int i= 1; i < 11; i++) 13 14 cout << a << " X " << i << * = * << (a * i) << "\n"; 15 16 17 Evoid doubl() 18 { 19 int a; 20 cout << "Enter a number: "; 21 cin >> a; 22 cout << "Double of value: " << (2 * a) << "\n"; 23 } 24 Evoid menu() { 25 int ch; 26 cout << "1: Display a Multiplication Table \n"; 27 cout << "2: Double a Value \n"; 28 cout << "3: Exit\n"; 29 cout << "Enter your choice: \n"; cin >> ch; 30 switch (ch) { 31 32 33 case 1: { Multitable(); 34 menu(); break; 35 36 } 37 case 2: { 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 -0-0 8 8 doubl(); menu(); break; case 3: { } default: cout << "Thank you\n"; break; printf("Wrong Input\n"); int main() { menu(); return 0;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

please read the full question. There is nothing wrong with my c++ code. I need help with the later parts of the question where I have to integrate Python. Your answer was not helpful for that.

Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY