Help please
Aim: The purpose is to practice using exceptions. Write a program with a while loop that asks for an employee's total monthly pay, days worked in the last month, hours worked in the last month. Then it outputs: pay rate per day and pay rate per hour for the employee for the last month. The program should have exception handling for these cases: division by zero, if days is a value that does not make sense (> 31 or <0) or hours does not make sense (>720 or <0). The program's while loop only exits when the total monthly pay entered is a negative value!
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <iostream>
#include <limits>
using namespace std;
int getInteger(int low, int high)
{
int num;
// check if input is valid or not
while (!(cin >> num) || (num < low || num > high))
{
// flush the cin data
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "The number is out of bounds: Try again : ";
}
return num;
}
float getPay()
{
float num;
// check if input is valid or not
while (!(cin >> num) || (num < 0))
{
// flush the cin data
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "The number is out of bounds: Try again : ";
}
return num;
}
float getPerDay(float pay, int days)
{
if (days == 0)
{
throw "division by zero for number of days";
}
return pay / days;
}
float getPerHours(float pay, int hours)
{
if (hours == 0)
{
throw "division by zero for number of hours";
}
return pay / hours;
}
int main()
{
float pay, perDay, perHour;
int day, hours;
while (1)
{
cout << "\nEmployee's total monthly pay : ";
pay = getPay();
if (pay == 0)
{
break;
}
cout << "Days worked in the last month : ";
day = getInteger(0, 31);
cout << "Hours worked in the last month : ";
hours = getInteger(0, 720);
try
{
perDay = getPerDay(pay, day);
cout << "pay rate per day : " << perDay << endl;
}
catch (const char *str)
{
cerr << str << '\n';
}
try
{
perHour = getPerHours(pay, hours);
cout << "pay rate per hour : " << perHour << endl;
}
catch (const char *str)
{
cerr << str << '\n';
}
}
return 0;
}

Kindly revert for any queries
Thanks.
Help please Aim: The purpose is to practice using exceptions. Write a program with a while...
C++ program
Please only (if) (else) statements No while statements use Write a program that takes rate and outputs the employee's wages for the week input employee's hours worked and regular pay as an Calculate employee's wages as follows: She receives her regular rate for the an first 40 hours, 1.5 times her regular rate for each hour between 40 and 50 hours, and double her regular rate for each hour over 50. For invalid inputs, in addition to outputting...
java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: • An empty string is given for the employee’s name. • An invalid value is given for the employee’s ID number. If you implemented this field as a string, then an empty string would be invalid. If you implemented this field as a numeric variable, then a negative number or...
Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...
PLEASE I NEED C# Objectives Learn the basics of exception handling. Background Exceptions are essentially unexpected situations. It is difficult to write a program that can handle all possible situations, as we have found out through the many programs we have written. For example, should your program accept accidental input? Does it use the metric system or the empirical system? Do users of your program know which system it uses? In order to deal with all these possibilities, exceptions were...
I have a Java question. (I'm using BlueJ.) I'm trying to program something that calculates pay roll. Most of it works, but I've identified two parts that don't: It labels all salaries as "Fulltime" no matter how many hours worked I input, and the do/while loop does something weird. The if/else statement I have for the fulltime vs part time is: if (hoursWorked < 40.0) { position = partTime; } else if (hoursWorked >= 40.0 || hoursWorked <= 168.0) {...
THIS IS WHAT I HAVE I NEED TO FIX IT SO:
hours_worked should not be inputed separately.
Get the hours as 40 40 40 40 or 40, 40, 40, 40 whichever
separator suits you.
How do I do this?
How would you change what I have in to it getting into that kind
of input.
Thank you!
class Employee:
again = 'y'
def __init__(self):
self.__rate = 7.25
self.__totalhour = 0
self.__regularpay = 0
self.__overtimepay = 0
self.__totalpay = 0
self.__tax...
Lesson is about Input validation, throwing exceptions, overriding toString Here is what I am supposed to do in the JAVA Language: Model your code from the Time Class Case Study in Chapter 8 of Java How to Program, Late Objects (11th Edition) by Dietel (except the displayTime method and the toUniversalString method). Use a default constructor. The set method will validate that the hourly employee’s rate of pay is not less than $15.00/hour and not greater than $30.00 and validate...
In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...
(JAVA Please) Program 1: FICA!? What’s FICA? If you’re taking this course, chances are that you’re going to make a pretty good salary – especially 3 to 5 years after you graduate. When you look at your paycheck, one of the taxes you pay is called FICA – or Federal Insurance Contributions Act. In simplest terms, it’s what funds our Social Security and Medicare systems (and the more that you work, the more you get). Interestingly, your employer will pay...
Program 1: Social Security Payout. If you’re taking this course, chances are that you’re going to make a pretty good salary – especially 3 to 5 years after you graduate. When you look at your paycheck, one of the taxes you pay is called Social Security. In simplest terms, it’s a way to pay into a system and receive money back when you retire (and the longer you work and the higher your salary, the higher your monthly benefit). Interestingly,...