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

T
EGE
29706)
Lesson 4 - Lab Assignment
ST 2362: C++ Programming II home > 14.17: CIS2362 LAB: Input errors with zyLabs
14.17 CIS2362 LAB: Input errors with zyLabs
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
485840.2632270.qx3zqy7
zyBooks catalog
GTC
Help
Transcribed Image Text:T EGE 29706) Lesson 4 - Lab Assignment ST 2362: C++ Programming II home > 14.17: CIS2362 LAB: Input errors with zyLabs 14.17 CIS2362 LAB: Input errors with zyLabs 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 485840.2632270.qx3zqy7 zyBooks catalog GTC Help
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
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