note : this question using C++ please, and please do not use any of this libraries. #include //nonstandard #include //beyond chapter nine #include //beyond chapter nine #include //a C library, not C++ Program requirements: You must use the function prototypes given below. Copy and paste them above the main function of your source code. In the main function, create a menu system to test the functions. Assume perfect input. Do not use an infinite loop. Do not exit a loop with a break If you naturally program using infinite loops then come up with a Boolean flag mechanism instead. Use exactly one return statement in main – the last statement. Exiting loops with break statements is discouraged because they can be unstructured. Exiting a loop is best handled by a well written continuation condition: while (continuation condition) {} Switch/case code usually requires break statements. Functions end with a return statement, not break. A return statement can be left out of void functions because the compiler will automatically place one at the end of the function.   Function 1 Write a function that … reads one or more positive numbers from the user in a loop leaves the loop whenever it encounters either zero or a negative number in the input outputs the count of positive numbers – do not output the largest number entered returns the largest number Once the largest value is returned have the calling function output the answer. The function prototype is as follows: int largest(); Note that you must use cin in this function. Do not use an array or objects in this function – we have not covered that yet. I recommend a while loop – that will allow you to read in integers one at a time and keep track of the largest number.   Function 2 This function will be a void function that will modify two reference values. Here is the function prototype: void numberCount(int &oddCount, int &evenCount); Write a function that reads a number from the user and returns the number of odd and even digits within that number.  Make sure that whenever this function reads the same input it produces the same output. You can assume that the user will type in no more than nine consecutive digits, so an int variable will be sufficient.  For example, when the user enters 382045, the number of odd digits is 2 and even digits is 4 (treating zero as an even number since that is how mathematicians view it). You must use integer math in this problem (hint –review integer division and integer remainder operations).   Make the calling function output the results – do not use cout in function 2.   Function main In the main function have exactly one return statement as the last statement. Create a loop that will call Functions 1 and 2 as many times as the user desires. Use logic to exit this loop - do not use a break statement. Display the following menu each time the loop executes: Welcome to my program! Please enter a-c to choose one of the following: (a) Find the largest of a list of positive numbers (type 0 to quit). (b) Count the odd and even digits in a number. (c) Quit this program.   Exit the loop using logic when the user enters ‘c’ to quit. If the user picks something other than a-c then display a friendly error message and continue the loop. Based on what character the user picks use either a switch statement (noting that within switch statements break statements are OK), or an if statement. With each type of input display some kind of corresponding output text message.

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
100%

note : this question using C++ please, and please do not use any of this libraries.

#include <bits/stdc++.h> //nonstandard

#include <sstream> //beyond chapter nine

#include <array> //beyond chapter nine

#include <stdlib.h> //a C library, not C++

Program requirements:

  • You must use the function prototypes given below. Copy and paste them above the main function of your source code.
  • In the main function, create a menu system to test the functions.
  • Assume perfect input.
  • Do not use an infinite loop. Do not exit a loop with a break If you naturally program using infinite loops then come up with a Boolean flag mechanism instead.
  • Use exactly one return statement in main – the last statement.
  1. Exiting loops with break statements is discouraged because they can be unstructured. Exiting a loop is best handled by a well written continuation condition:

while (continuation condition) {}

  1. Switch/case code usually requires break statements.
  2. Functions end with a return statement, not break. A return statement can be left out of void functions because the compiler will automatically place one at the end of the function.

 

Function 1

Write a function that …

  • reads one or more positive numbers from the user in a loop
  • leaves the loop whenever it encounters either zero or a negative number in the input
  • outputs the count of positive numbers – do not output the largest number entered
  • returns the largest number

Once the largest value is returned have the calling function output the answer. The function prototype is as follows:

int largest();

Note that you must use cin in this function. Do not use an array or objects in this function – we have not covered that yet. I recommend a while loop – that will allow you to read in integers one at a time and keep track of the largest number.

 

Function 2

This function will be a void function that will modify two reference values. Here is the function prototype: void numberCount(int &oddCount, int &evenCount);

Write a function that reads a number from the user and returns the number of odd and even digits within that number.  Make sure that whenever this function reads the same input it produces the same output. You can assume that the user will type in no more than nine consecutive digits, so an int variable will be sufficient.  For example, when the user enters 382045, the number of odd digits is 2 and even digits is 4 (treating zero as an even number since that is how mathematicians view it). You must use integer math in this problem (hint –review integer division and integer remainder operations).

 

Make the calling function output the results – do not use cout in function 2.

 

Function main

In the main function have exactly one return statement as the last statement. Create a loop that will call Functions 1 and 2 as many times as the user desires. Use logic to exit this loop - do not use a break statement. Display the following menu each time the loop executes:

Welcome to my program! Please enter a-c to choose one of the following:

(a) Find the largest of a list of positive numbers (type 0 to quit).

(b) Count the odd and even digits in a number.

(c) Quit this program.

 

Exit the loop using logic when the user enters ‘c’ to quit. If the user picks something other than a-c then display a friendly error message and continue the loop. Based on what character the user picks use either a switch statement (noting that within switch statements break statements are OK), or an if statement. With each type of input display some kind of corresponding output text message.

Expert Solution
Step 1

Required:

Write a program that shows the following menu:

 

Welcome to my program! Please enter a-c to choose one of the following:

(a) Find the largest of a list of positive numbers (type 0 to quit).

(b) Count the odd and even digits in a number.

(c) Quit this program.

 

All code and screenshots are given in the next steps.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
ADT and Class
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.
Similar questions
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