Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134521176
Author: SAVITCH
Publisher: PEARSON
Question
Book Icon
Chapter 16, Problem 7PP
Program Plan Intro

  • Include required library files.
  • Define a class named “ArrOutOfRangeErr”.
  • Declare the required variables, constructors and function inside the access specifier “public” and “private”.
  • Define a “testExcep()” function to test the exception.
    • Using exception, set and get the values.
  • Define a “create2DArr()” function to create an two-dimensional array.
  • Define a “check_args()” function to check the validity and return the message if something is wrong.
  • Define a “set()” function to store values.
  • Define a “get()” function to retrieve the values.
  • Define a default constructor for no messages.
  • Define a parameterized constructor for row and column data.
  • Define a “getMsg()” function to return the exception message string.
  • Define a “getRows()” function to return the number of rows.
  • Define a “getCols()” function to return the number of columns.
  • Define a “getDesiredRow()” function to return the requested row number.
  • Define a “getDesiredColumn()” function to return the requested column number.
  • Define a “writeErr()” function to write the error message.
  • Define a “main()” function.
    • Declare the required variables.
    • Create a 2D array for rows and columns.
    • Populate the rows and columns.
    • Print the array contents using “for” loop.
    • Then test the some boundary cases.

Blurred answer
Students have asked these similar questions
Language: Java Rewrite the ADA source code in Java.Within the Java version of the code, change the second half of the first loop so that all assignments to the counting array 'Freq()' are updated in the EXCEPTION portion of the code. There should be no valid updates to 'Freq()' anywhere else in the loop.ADA source code:with Ada.Text_IO , Ada.Integer_Text_IO ;use Ada.Text_IO, Ada.Integer_Text_IO;procedure Grade_Distribution isFreq: array (1..10) of Integer := (others => 0);New_Grade : Natural;Index,Limit_1,Limit_2 : Integer;beginGrade_Loop:loopbeginGet(New_Grade);exceptionwhen Constraint_Error =>exit Grade_Loop;end;Index := New_Grade/10 + 1;beginFreq(Index) := Freq(Index) +1 ;exceptionwhen Constraint_Error =>if New_Grade = 100 thenFreq(10) := Freq(10) + 1;elsePut("Error -- new grade: ");Put(New_Grade);Put(" is out of range");New_Line;end if;end;end loop Grade_Loop;Put("Limits Frequency");New_Line; New_Line;for Index in 0..8 loopLimit_1 := 10 * Index;Limit_2 := Limit_1 + 9;if…
Create a Java program with a method that searches an integer array for a specified integer value (see help with starting the method header below). If the array contains the specified integer, the method should return its index in the array. If not, the method should throw an Exception stating "Element not found in array" and end gracefully. Test the method in main with an array that you make and with user input for the "needle".public static int returnIndex(int[ ] haystack, int needle) {
Write a program that takes an integer array and perform following operations sum, average, percentage,. The user must non zero integers. If they were not an integer, the program would throw a NumberFormatException if user try to input string instead of integer value. If denominator were Zero, the program would throw an ArithmeticException and Display the exception.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT