Write a program that takes in three integers as inputs and outputs the largest value. Use a try block to perform all the statements. Use a catch block to catch any ios_base: failure caused by missing inputs and output the number of inputs read and the largest value. Output "No max" if no inputs are read. Note: Because inputs are pre-entered when running a program in the zyLabs environment, the system throws the ios_base: failure when inputs are missing. Test the program by running the program in the Develop mode. Hint: Use a counter to keep track of the number of inputs read and compare the inputs accordingly in the catch block when an exception is caught. Ex: If the input is: 375 the output is: 7 Ex: If the input is: 3 the system throws the ios_base::failure and outputs: 1 input (s) read: Max is 3 Ex: If no inputs are entered: the system throws the ios_base: failure and outputs: 0 input (s) read: No max
Write a program that takes in three integers as inputs and outputs the largest value. Use a try block to perform all the statements. Use a catch block to catch any ios_base: failure caused by missing inputs and output the number of inputs read and the largest value. Output "No max" if no inputs are read. Note: Because inputs are pre-entered when running a program in the zyLabs environment, the system throws the ios_base: failure when inputs are missing. Test the program by running the program in the Develop mode. Hint: Use a counter to keep track of the number of inputs read and compare the inputs accordingly in the catch block when an exception is caught. Ex: If the input is: 375 the output is: 7 Ex: If the input is: 3 the system throws the ios_base::failure and outputs: 1 input (s) read: Max is 3 Ex: If no inputs are entered: the system throws the ios_base: failure and outputs: 0 input (s) read: No max
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...
Related questions
Question
main.cpp
#include <iostream>
using namespace std;
int main() {
cin.exceptions(ios::failbit); // Allow cin to throw exceptions
int val1;
int val2;
int val3;
int max;
val1 = 0;
val2 = 0;
val3 = 0;
/* Type your code here. */
return 0;
}
Please complete this code in C++ thank you.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY