Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package wageCalculator;
- import javax.swing.*;
- import java.io.*;
- import java.util.*;
- public class wageCalculator {
- public static void main(String[] args) throws FileNotFoundException {
- int totalWages;
- int totalJourneyLength;
- String recommendedJourneyCost;
- String fileName = "a:\\shipJourneyInfo.dat";
- int convertedRecommendedJourneyCost;
- recommendedJourneyCost = JOptionPane.showInputDialog(null, "Please enter the recommended journey cost:", "wageCalculator v0.1", JOptionPane.INFORMATION_MESSAGE);
- convertedRecommendedJourneyCost = Integer.parseInt(recommendedJourneyCost);
- Scanner inFile = new Scanner(new FileReader("a:\\shipJourneyInfo.dat"));
- String shipName = null;
- String shipID;
- int lengthOfJourney;
- int numberOfCrew;
- double payRate = 0;
- double countingPay = 0;
- int totalLengthOfJourney = 0;
- int count = 0;
- while (inFile.hasNext())
- {
- shipName = inFile.next();
- shipID = inFile.next();
- lengthOfJourney = inFile.nextInt();
- numberOfCrew = inFile.nextInt();
- //totalLengthOfJourney = totalLengthOfJourney + lengthOfJourney;
- System.out.println(shipName);
- System.out.println(shipID);
- System.out.println(lengthOfJourney);
- System.out.println(numberOfCrew);
- while (inFile.hasNextDouble())
- {
- count = 0;
- countingPay = 0;
- while (count < numberOfCrew)
- {
- payRate = inFile.nextDouble();
- System.out.println(payRate);
- countingPay = countingPay + (lengthOfJourney * payRate);
- count++;
- }
- }
- if (countingPay <= convertedRecommendedJourneyCost)
- {
- PrintWriter outFile = new PrintWriter("a:\\wagedaily.out");
- outFile.println(countingPay);
- outFile.close();
- }
- else
- {
- JOptionPane.showMessageDialog(null, "WARNING: PAY OVER RECOMMENDED LIMIT FOR: "+ (shipName) + "\nAMOUNT OF PAY: " + "£" + (countingPay) , "WARNING!", JOptionPane.WARNING_MESSAGE);
- }
- System.out.println(countingPay);
- }
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement