CSIS 212 – Week 2 Project
A
//A -- Takes in a input of 3 employees, payrates, and hours worked.
// Calulates the employee's pay with consideration of overtime.
//CSIS 212-B01
//Citations **
//** Formatting decimal points --
package main;
import .Scanner;
public class App ...
CSIS 212 – Week 2 Project
App.java
//App.java -- Takes in a input of 3 employees, payrates, and hours worked.
//Calulates the employee's pay with consideration of overtime.
//CSIS 212-B01
//Citations **
//** Formatting decimal points -- https://stackoverflow.com/questions/42334771/double-with-
exactly-two-decimal-digits-in-java-without-java-text-decimalfomat */
package main;
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Bradley Bentow - Assignment #2 \n");
//Variable declaration
Employee employee; Scanner input = null;
int EmployeeIterator = 1; double hoursWorked; double employeePayRate;
//Properly using a Try finally to prevent a memory leak of Scanner. try
{
//Instantiate Scanner before the while loop. input = new Scanner(System.in);
do {
//Take in the Employee's pay rate, store as a double System.out.print("Employee's hourly pay rate: "); employeePayRate = input.nextDouble();
//Take in the Employee's working hours, store as a double System.out.print("Hours the employee worked: "); hoursWorked = input.nextDouble();
//Instantiate a new Employee object and pass in the pay rate and hours worked,
//The class is abstracted and will automatically make the total pay available
//with employee.EmployeeTotal
employee = new Employee(hoursWorked, employeePayRate);
//Now that everything is completed, we can show the user the completed string with
//the wanted calculations.
System.out.printf("Pay for Employee %d is: $%.2f\n", EmployeeIterator, employee.EmployeeTotal);
//Add one to the iterator so the loop doesn't run forever. EmployeeIterator += 1;
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller EXAMINER001. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $10.99. You're not tied to anything after your purchase.