Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. /*
  2. *
  3. * Program: Prog
  4. *
  5. * Programmer: An Huynh
  6. * Date: X/X/X
  7. * School: Green Hope High School
  8. *
  9. * Description:
  10. *
  11. *
  12. * Learned:
  13. *
  14. * Difficulties:
  15. */
  16. package com.company;
  17. import java.io.File;
  18. import java.io.FileNotFoundException;
  19. import java.util.Scanner;
  20.  
  21. public class Prog213aFIXED {
  22. public static void main(String[] args) {
  23. //Initializing and declaring objects and variables
  24. double hoursDay, totalHours = 0, totalCash = 0, dayWeek = 0, week = 0, earnDay = 0;
  25.  
  26. //Sets up scanner to read from file
  27. Scanner inFile = null;
  28. try {
  29. inFile = new Scanner(new File("C:\\Users\\Cyber\\Desktop\\AP Computer Science\\Text Files\\Prog213a.dat"));
  30. } catch (FileNotFoundException e) {
  31. System.out.println("File not found!");
  32.  
  33. //Stop program if no file found
  34. System.exit(0);
  35. }
  36.  
  37. //Main Section of the code
  38. do{//Loops through all of the values in the text file
  39. //Prints Header
  40. if (dayWeek == 0) {
  41. //System.out.print("Hours Worked:");
  42. }
  43. hoursDay = inFile.nextInt();
  44. //System.out.print(" " + hoursDay);
  45. dayWeek++;
  46.  
  47. for(int i = 1; i <= hoursDay; i++) { //Calculates money per hour for that day
  48. //System.out.println(i + " Out of " + hoursDay);
  49. totalHours++;
  50. if (i <= 8) { //Checks if they worked over 8 hours
  51. if (totalHours > 40) {
  52. earnDay += 30.00 + 15.00;
  53. System.out.println(earnDay);
  54. } else{
  55. earnDay += 30.00;
  56. System.out.println(earnDay);
  57. }
  58. } else{ //If they didn't work for 8 hours
  59. if (totalHours > 40) {
  60. earnDay += 30.0 + 15.0 + 25.50;
  61. System.out.println(earnDay);
  62. }else{
  63. earnDay += 30.00 + 25.50;
  64. System.out.println(earnDay);
  65. }
  66. }
  67. }
  68.  
  69. if (dayWeek == 6) {//Checks if its Saturday
  70. earnDay *= 2.25;
  71. System.out.println("ITS SATURDAY BOISSSSSS: " + earnDay);
  72. } else if (dayWeek == 7) {//Checks if its Sunday
  73. earnDay *= 1.5;
  74. System.out.println("ITS SUNDAY BOISSSSSS: " + earnDay);
  75. }
  76.  
  77. //Calculates total money earned
  78. totalCash += earnDay;
  79. System.out.println("Total Cash: " + totalCash);
  80. earnDay = 0;
  81.  
  82. if (dayWeek >= 7){
  83. week++;
  84. System.out.println("\nWeek #" + week + " $" + totalCash + "\n");
  85. dayWeek = 0;
  86. totalHours = 0;
  87. totalCash = 0;
  88. }
  89. }while(inFile.hasNext() != false);
  90.  
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement