import java.util.Scanner;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

import java.util.Scanner;

/**
This program demonstrates a solution to the
Payroll Class programming challenge.
*/

public class PayrollDemo
{
    public static void main(String[] args)
    {
        // Variables for input
        String name; // An employee's name
        int id; // An employee's ID number
        double payRate; // An employee's pay rate
        double hoursWorked; // The number of hours worked

        // Create a Scanner object for keyboard input.
        Scanner keyboard = new Scanner(System.in);

        // Get the employee's name.
        System.out.print("Enter the employee's name: ");
        name = keyboard.nextLine();

        // Get the employee's ID number.
        System.out.print("Enter the employee's ID number: ");
        id = keyboard.nextInt();

        // Get the employee's pay rate.
        System.out.print("Enter the employee's hourly pay rate: ");
        payRate = keyboard.nextDouble();

        // Get the number of hours worked by the employee.
        System.out.print("Enter the number of hours worked " +
" by the employee: ");
        hoursWorked = keyboard.nextDouble();

        // Create a Payroll object and store the data in it.
        Payroll worker = new Payroll(name, id);
        worker.setPayRate(payRate);
        worker.setHoursWorked(hoursWorked);

        // Display the employee's payroll data.
        System.out.println("\nEmployee Payroll Data");
        System.out.println("Name: " + worker.getName());
        System.out.println("ID Number: " + worker.getIdNumber());
        System.out.println("Hourly pay rate: " + worker.getPayRate());
        System.out.println("Hours worked: " + worker.getHoursWorked());
        System.out.println("Gross pay: $" + worker.getGrossPay());
    }
}

 

can you do these following this instruction. Homework assignment 2: Page 756 in the testbook, problem number 5. Each of the exceptions should have a statement indicating what the error is so that when the getMessage() method is called in the Demo program it will printout which exception was thrown. Each exception class should be in a separate file. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Greatest Common Divisor
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education