Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Program: Prog
- *
- * Programmer: An Huynh
- * Date: X/X/X
- * School: Green Hope High School
- *
- * Description:
- *
- *
- * Learned:
- *
- * Difficulties:
- */
- package com.company;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Prog213aFIXED {
- public static void main(String[] args) {
- //Initializing and declaring objects and variables
- double hoursDay, totalHours = 0, totalCash = 0, dayWeek = 0, week = 0, earnDay = 0;
- //Sets up scanner to read from file
- Scanner inFile = null;
- try {
- inFile = new Scanner(new File("C:\\Users\\Cyber\\Desktop\\AP Computer Science\\Text Files\\Prog213a.dat"));
- } catch (FileNotFoundException e) {
- System.out.println("File not found!");
- //Stop program if no file found
- System.exit(0);
- }
- //Main Section of the code
- do{//Loops through all of the values in the text file
- //Prints Header
- if (dayWeek == 0) {
- //System.out.print("Hours Worked:");
- }
- hoursDay = inFile.nextInt();
- //System.out.print(" " + hoursDay);
- dayWeek++;
- for(int i = 1; i <= hoursDay; i++) { //Calculates money per hour for that day
- //System.out.println(i + " Out of " + hoursDay);
- totalHours++;
- if (i <= 8) { //Checks if they worked over 8 hours
- if (totalHours > 40) {
- earnDay += 30.00 + 15.00;
- System.out.println(earnDay);
- } else{
- earnDay += 30.00;
- System.out.println(earnDay);
- }
- } else{ //If they didn't work for 8 hours
- if (totalHours > 40) {
- earnDay += 30.0 + 15.0 + 25.50;
- System.out.println(earnDay);
- }else{
- earnDay += 30.00 + 25.50;
- System.out.println(earnDay);
- }
- }
- }
- if (dayWeek == 6) {//Checks if its Saturday
- earnDay *= 2.25;
- System.out.println("ITS SATURDAY BOISSSSSS: " + earnDay);
- } else if (dayWeek == 7) {//Checks if its Sunday
- earnDay *= 1.5;
- System.out.println("ITS SUNDAY BOISSSSSS: " + earnDay);
- }
- //Calculates total money earned
- totalCash += earnDay;
- System.out.println("Total Cash: " + totalCash);
- earnDay = 0;
- if (dayWeek >= 7){
- week++;
- System.out.println("\nWeek #" + week + " $" + totalCash + "\n");
- dayWeek = 0;
- totalHours = 0;
- totalCash = 0;
- }
- }while(inFile.hasNext() != false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement