Need C ++    this program will determine, based on the age input, whether the user is old enough to vote for this program, you will use the try and catch method to deal with errors in inputted data  under try: create an if, else decision structure to determine if the user is old enough to vote (age greater than or equal to 18) if their age is less than 18 send them to another function, called tooYoung and pass age to it tooYoung function will test whether the age is less than zero if it is, it will trigger a string exception which says:  "ERROR:  Cannot have a negative age!" otherwise, the tooYoung function will return the number of years until the user is 18 assign the returned value from the function to an integer variable called years display the returned value in a sentence that says: "You will be old enough in "<

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

Need C ++ 

 

  • this program will determine, based on the age input, whether the user is old enough to vote
  • for this program, you will use the try and catch method to deal with errors in inputted data 
  • under try:
    • create an if, else decision structure to determine
      • if the user is old enough to vote (age greater than or equal to 18)
      • if their age is less than 18
        • send them to another function, called tooYoung and pass age to it
          • tooYoung function will test whether the age is less than zero
          • if it is, it will trigger a string exception which says:  "ERROR:  Cannot have a negative age!"
          • otherwise, the tooYoung function will return the number of years until the user is 18
        • assign the returned value from the function to an integer variable called years
        • display the returned value in a sentence that says: "You will be old enough in "<<years <<" years.
  • the catch part of the  main function will call out the same exception string that is listed in the tooYoung() function.
  • save and test your program with a negative number, a number between 0 and 17, and a number 18 or greater.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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