Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. package wageCalculator;
  2.  
  3. import javax.swing.*;
  4. import java.io.*;
  5. import java.util.*;
  6.  
  7. public class wageCalculator {
  8.  
  9. public static void main(String[] args) throws FileNotFoundException {
  10.  
  11. int totalWages;
  12. int totalJourneyLength;
  13. String recommendedJourneyCost;
  14. String fileName = "a:\\shipJourneyInfo.dat";
  15. int convertedRecommendedJourneyCost;
  16.  
  17.  
  18. recommendedJourneyCost = JOptionPane.showInputDialog(null, "Please enter the recommended journey cost:", "wageCalculator v0.1", JOptionPane.INFORMATION_MESSAGE);
  19. convertedRecommendedJourneyCost = Integer.parseInt(recommendedJourneyCost);
  20.  
  21. Scanner inFile = new Scanner(new FileReader("a:\\shipJourneyInfo.dat"));
  22.  
  23.  
  24. String shipName = null;
  25. String shipID;
  26. int lengthOfJourney;
  27. int numberOfCrew;
  28. double payRate = 0;
  29. double countingPay = 0;
  30. int totalLengthOfJourney = 0;
  31.  
  32. int count = 0;
  33.  
  34. while (inFile.hasNext())
  35.  
  36. {
  37. shipName = inFile.next();
  38. shipID = inFile.next();
  39. lengthOfJourney = inFile.nextInt();
  40. numberOfCrew = inFile.nextInt();
  41.  
  42.  
  43.  
  44. //totalLengthOfJourney = totalLengthOfJourney + lengthOfJourney;
  45.  
  46. System.out.println(shipName);
  47. System.out.println(shipID);
  48. System.out.println(lengthOfJourney);
  49. System.out.println(numberOfCrew);
  50.  
  51. while (inFile.hasNextDouble())
  52. {
  53. count = 0;
  54. countingPay = 0;
  55.  
  56. while (count < numberOfCrew)
  57. {
  58. payRate = inFile.nextDouble();
  59. System.out.println(payRate);
  60.  
  61. countingPay = countingPay + (lengthOfJourney * payRate);
  62.  
  63. count++;
  64.  
  65. }
  66.  
  67. }
  68.  
  69. if (countingPay <= convertedRecommendedJourneyCost)
  70. {
  71. PrintWriter outFile = new PrintWriter("a:\\wagedaily.out");
  72. outFile.println(countingPay);
  73.  
  74. outFile.close();
  75. }
  76. else
  77. {
  78. JOptionPane.showMessageDialog(null, "WARNING: PAY OVER RECOMMENDED LIMIT FOR: "+ (shipName) + "\nAMOUNT OF PAY: " + "£" + (countingPay) , "WARNING!", JOptionPane.WARNING_MESSAGE);
  79. }
  80. System.out.println(countingPay);
  81.  
  82.  
  83. }
  84.  
  85. System.exit(0);
  86. }
  87.  
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement