in c++ Write a function named createOneStudent that will read in from the user the student info: id, name and gpa. It will use try-catch to handle the exception if the user provides a negative id or gpa that is out of bound (< 0.0 or > 4.0) by asking the user to re-enter them. It must provide the correct reason for the error and the actual error value. Then it will allow the user to try up to 3 times. This function will return the pointer of a newly created Student object or nullptr if the info is still incorrect. Note that this function can and will use cin and cout to read in values from the user. Here is an example of a run up to 3 times: Enter ID: -1 Enter GPA: 4.0 Enter name: John Smith Exception: negative id: -1 Enter ID: 1234 Enter GPA: 5.0 Enter name: John Smith Exception: out of bound gpa: 5.00 Enter ID: 1234 Enter GPA: 4.0 Enter name: John Smith ID(1234) NAME(John Smith) GPA(4.00) Here is an example of a run of 3 times and still not able to create it: Enter ID: 1234 Enter GPA: -1.25 Enter name: John Smith Exception: out of bound gpa: -1.25 Enter ID: 1234 Enter GPA: 5.5 Enter name: John Smith Exception: out of bound gpa: 5.50 Enter ID: -1234 Enter GPA: 4.0 Enter name: John Smith Exception: negative id: -1234 Unable to create student

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

in c++

Write a function named createOneStudent that will read in from the user the
student info: id, name and gpa.
It will use try-catch to handle the exception if the user provides a negative id or
gpa that is out of bound (< 0.0 or > 4.0) by asking the user to re-enter them. It
must provide the correct reason for the error and the actual error value. Then it
will allow the user to try up to 3 times. This function will return the pointer of a
newly created Student object or nullptr if the info is still incorrect.
Note that this function can and will use cin and cout to read in values from the
user.

Here is an example of a run up to 3 times:
Enter ID: -1
Enter GPA: 4.0
Enter name: John Smith
Exception: negative id: -1
Enter ID: 1234
Enter GPA: 5.0
Enter name: John Smith
Exception: out of bound gpa: 5.00
Enter ID: 1234
Enter GPA: 4.0
Enter name: John Smith
ID(1234) NAME(John Smith) GPA(4.00)

Here is an example of a run of 3 times and still not able to create it:
Enter ID: 1234
Enter GPA: -1.25
Enter name: John Smith
Exception: out of bound gpa: -1.25
Enter ID: 1234
Enter GPA: 5.5
Enter name: John Smith
Exception: out of bound gpa: 5.50
Enter ID: -1234
Enter GPA: 4.0
Enter name: John Smith
Exception: negative id: -1234
Unable to create student 

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Exception Handling Keywords
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage