bartleby

Concept explainers

Question
Book Icon
Chapter 11, Problem 5PC
Program Plan Intro

  • Define a class named “Payroll”.
    • Declare the required variables.
    • Define a parameterize constructor to set “name” and “Id”.
    • Define a “setName()” method to set “name”.
    • Define a “setIdNum()” method to set “id”.
    • Define a “setPayRate()” method to check the rate and throw “InvalidHrlyRateExcep” exception.
    • Define a “setHrsWrked()” method to check the hours and throw “InvalidHrsExcep” exception.
    • Define a “getName()” method to return name.
    • Define a “getIdNum()” method to return Id number.
    • Define a “getPayRate()” method to return pay rate.
    • Define a “getHrsWrked()” method to return hours worked.
    • Define a “getGrossPay()” method to compute and return gross pay.
  • Define a class named “InvalidNameExcep” that extends “Exception” class.
    • Define a constructor with no parameters.
      • Call “super()” method to print invalid name.
  • Define a class named “InvalidHrlyRateExcep” that extends “Exception” class.
    • Define a constructor with no parameters.
      • Call “super()” method to print invalid hour pay rate message.
    • Define a constructor with one parameter.
      • Call “super()” method to print invalid hour pay rate.
  • Define a class named “InvalidHrsExcep” that extends “Exception” class.
    • Define a constructor with no parameters.
      • Call “super()” method to print invalid number of hours message.
    • Define a constructor with one parameter.
      • Call “super()” method to print invalid number of hours.
  • Define a class named “InvalidIDExcep” that extends “Exception” class.
    • Define a constructor with no parameters.
      • Call “super()” method to print invalid ID message.
    • Define a constructor with one parameter.
      • Call “super()” method to print invalid ID.
  • Define a class named “PayrollCheck”.
    • Define a “main()” method to check payroll exception.
      • Create an object or reference variable for a “Payroll” class.
      • “try” block to call the “Payroll” constructor with empty string for name.
      • “catch” block to catch the exception and print the error message.
      • Same for the following “try…catch” block to check invalid Id, invalid hourly pay rate, invalid number of hours worked and print the corresponding error messages.

Blurred answer
Students have asked these similar questions
C++ PROGRAM STRING MANIPULATION Create a class Class1 with a string data member ‘paragraph’. Provide a constructor and getParagraph() method in the class. The constructor just assigns NULL to the data member. getParagraph() method must read a paragraph from user. The paragraph should contain at least 30 words. If there are less than 20 words, the program must ask user to enter paragraph again. Create another class Class2, and make it a friend of the class Class1. Provide a function getSubString(Class1 &obj1, int startIndex, int lastIndex) with return type string in the class Class2 which accepts an object of class Class1 (by reference) and two integers. The getSubString() function should return the substring starting from location startIndex and ending at location lastIndex. Class2 must also contain a store() function that stores the substring in a file. Print screenshot of substring stored in file as well.
C++ Visual Studio 2019  Complete #13. Dependent  #1 Employee and ProductionWorker classes showing below. Modify the Employee and ProductionWorker classes so they throw exceptions when the following errors occur: The Employee class should throw an exception named InvalidEmployeeNumber when it receives an employee number that is less than 0 or greater than 9999. The ProductionWorker class should throw an exception named InvalidShift when it receives an invalid shift. The ProductionWorker class should throw an exception named InvalidPayRate when it receives a negative number for the hourly pay rate. Write a driver program that demonstrates how each of these exception conditions works.  #1 Employee and ProductionWorker classes #include <string>#include <iostream>#include <iomanip>using namespace std; class Employee{private:    string name;        // Employee name    string number;        // Employee number    string hireDate;    // Hire date public:    // Default…
Welcome Assignment ### welcome_assignment_answers ### Input - All eight questions given in the assignment. ### Output - The right answer for the specific question.   def welcome_assignment_answers(question):    # The student doesn't have to follow the skeleton for this assignment.    # Another way to implement it is using "case" statements similar to C.    if question == "Are encoding and encryption the same? - Yes/No":        answer = "The student should type the answer here"    elif question == "Is it possible to decrypt a message without a key? - Yes/No":        answer = "The student should type the answer here"    return (answer) # Complete all the questions. if __name__ == "__main__":    # use this space to debug and verify that the program works    debug_question = "Are encoding and encryption the same? - Yes/No"    print(welcome_assignment_answers(debug_question)) As you can see, the first two questions are already in the skeleton code. Please follow the first two questions…

Chapter 11 Solutions

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

Ch. 11.1 - What is the call stack? What is a stack trace?Ch. 11.1 - Prob. 11.12CPCh. 11.1 - Prob. 11.13CPCh. 11.1 - Prob. 11.14CPCh. 11.2 - What does the throw statement do?Ch. 11.2 - Prob. 11.16CPCh. 11.2 - Prob. 11.17CPCh. 11.2 - Prob. 11.18CPCh. 11.2 - Prob. 11.19CPCh. 11.3 - What is the difference between a text file and a...Ch. 11.3 - What classes do you use to write output to a...Ch. 11.3 - Prob. 11.22CPCh. 11.3 - What class do you use to work with random access...Ch. 11.3 - What are the two modes that a random access file...Ch. 11.3 - Prob. 11.25CPCh. 11 - Prob. 1MCCh. 11 - Prob. 2MCCh. 11 - Prob. 3MCCh. 11 - Prob. 4MCCh. 11 - FileNotFoundException inherits from __________. a....Ch. 11 - Prob. 6MCCh. 11 - Prob. 7MCCh. 11 - Prob. 8MCCh. 11 - Prob. 9MCCh. 11 - Prob. 10MCCh. 11 - Prob. 11MCCh. 11 - Prob. 12MCCh. 11 - Prob. 13MCCh. 11 - Prob. 14MCCh. 11 - Prob. 15MCCh. 11 - This is the process of converting an object to a...Ch. 11 - Prob. 17TFCh. 11 - Prob. 18TFCh. 11 - Prob. 19TFCh. 11 - True or False: You cannot have more than one catch...Ch. 11 - Prob. 21TFCh. 11 - Prob. 22TFCh. 11 - Prob. 23TFCh. 11 - Prob. 24TFCh. 11 - Find the error in each of the following code...Ch. 11 - // Assume inputFile references a Scanner object,...Ch. 11 - Prob. 3FTECh. 11 - Prob. 1AWCh. 11 - Prob. 2AWCh. 11 - Prob. 3AWCh. 11 - Prob. 4AWCh. 11 - Prob. 5AWCh. 11 - Prob. 6AWCh. 11 - The method getValueFromFile is public and returns...Ch. 11 - Prob. 8AWCh. 11 - Write a statement that creates an object that can...Ch. 11 - Write a statement that opens the file...Ch. 11 - Assume that the reference variable r refers to a...Ch. 11 - Prob. 1SACh. 11 - Prob. 2SACh. 11 - Prob. 3SACh. 11 - Prob. 4SACh. 11 - Prob. 5SACh. 11 - Prob. 6SACh. 11 - What types of objects can be thrown?Ch. 11 - Prob. 8SACh. 11 - Prob. 9SACh. 11 - Prob. 10SACh. 11 - What is the difference between a text file and a...Ch. 11 - What is the difference between a sequential access...Ch. 11 - What happens when you serialize an object? What...Ch. 11 - TestScores Class Write a class named TestScores....Ch. 11 - Prob. 2PCCh. 11 - Prob. 3PCCh. 11 - Prob. 4PCCh. 11 - Prob. 5PCCh. 11 - FileArray Class Design a class that has a static...Ch. 11 - File Encryption Filter File encryption is the...Ch. 11 - File Decryption Filter Write a program that...Ch. 11 - TestScores Modification for Serialization Modify...Ch. 11 - Prob. 10PC
Knowledge Booster
Background pattern image
Computer Science
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
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:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning