Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.50 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.io.*;
  3. public class Prog213a
  4. {
  5.     public static void main(String args[])
  6.     {
  7.         Scanner inFile = null;
  8.         int count = 0;
  9.         double totalweekWage=0, sunBonus=0, extraWage=0, weekWage=0;
  10.         double weekBonus=0, satBonus=0, sunWage=0;
  11.         double satWage=0, normalWage=0, weekHour=0;
  12.         try
  13.             {
  14.                 inFile = new Scanner (new File("prog213a.dat"));
  15.             }
  16.         catch (FileNotFoundException e)
  17.             {
  18.             System.out.println ("File not found!");
  19.             System.exit (0);
  20.             }
  21.        
  22.         while(inFile.hasNext())
  23.         {  
  24.             int num=inFile.nextInt();
  25.             for(int x = 1; x <= 7; x++)
  26.             {
  27.            
  28.             count++;
  29.                if(x==1)
  30.                {
  31.                   sunWage=num*10;
  32.                   sunBonus=sunWage/2;
  33.  
  34.               }
  35.               while(x==2 || x==3 || x==4 || x==5 || x==6)
  36.               {
  37.               if(num>8)
  38.               {
  39.                  normalWage=num*10;
  40.                  extraWage= (num-8)*1.50;
  41.               }
  42.               weekHour+=num;
  43.               weekWage=10*weekHour;
  44.               if(weekHour>40)
  45.               {
  46.                  weekBonus=(weekHour-40)*2.50;
  47.               }
  48.               }
  49.               if(x==7)
  50.               {
  51.                  satWage=num*10;
  52.                  satBonus=satWage*1.25;
  53.               }
  54.                 totalweekWage=sunWage+sunBonus+extraWage+weekWage+weekBonus+satWage+satBonus;
  55.                 System.out.println("Week # " + count + " $"+ totalweekWage);
  56.                      
  57.                 }
  58.             }
  59.             System.out.println();
  60.         inFile.close();
  61.         }
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement