The requirements are:
1. Creat public/private classes with at least 7 functions: next6ed (recursion)
2. create an input text file (*we have this done)
3. calculate hors/overtime (*we have the code for this)
4. taxes: recursion (need help on this)
5. passing parameters between classes
6. create an output txt file of checks/ stub (*we have this done)
7. open & close input/output txt file (*we have this done)
Here is what the input file looks like and we need to read in all the profiles to the outfile. Our code right now does the rock n roll, we need to read in the profile Darth Raiders, Oh Masterful One, Whaz-up, into the outfile so it looks like the rock n roll. could this be done with a simple for loop?
Rock N Roll 112-23-3445 56 5.26 .06 .22 Darth Raiders 010-10-1010 40 28.00 .004 .075 Oh Masterful One Aaa-bb-cccc 47.5 13.78 .8 .03 Whaz-up 224-46-6880 37.25 16.66 .888 .094
***Our code***
import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
public class Business
{
private static double RegularPay, OvertimePay, GrossPay, StateTax, FederalTax, TotalDeductions,
NetPay, HrPay, TotalHrs, MinHour = 40, StateTaxRate, FederalTaxRate;
private static int TotalHours;
private static String name, SocialSecurity;
static Scanner scan = new Scanner(System.in);
static FileOutputStream OutFile;
static PrintStream print;
static DecimalFormat fmt = new DecimalFormat("0.##");
static DecimalFormat fmt2 = new DecimalFormat(".##");
public static void main(String[] args)throws IOException
{
Business business = new Business();
business.InOutFile();
}
public static void InOutFile()throws FileNotFoundException
{
String Text = null;
Text = new String();
Scanner InFile = new Scanner(new FileReader("C:\\Documents and Settings\\220008514\\My Documents\\InFile.txt"));
try
{
OutFile = new FileOutputStream("OutFile.txt");
print = new PrintStream(OutFile);
}
catch(Exception e)
{
System.out.println("Could not load file");
}
name = InFile.nextLine();
SocialSecurity = InFile.nextLine();
TotalHrs = InFile.nextInt();
HrPay = InFile.nextDouble();
if (TotalHrs <= MinHour)
RegularPay = (TotalHrs * HrPay);
else
RegularPay = (MinHour * HrPay);
OvertimePay = (TotalHrs - MinHour) * HrPay * 1.5;
GrossPay = RegularPay + OvertimePay;
StateTaxRate = InFile.nextDouble();
StateTax = GrossPay * StateTaxRate;
FederalTaxRate = InFile.nextDouble();
FederalTax = GrossPay * FederalTaxRate;
TotalDeductions = StateTax + FederalTax;
NetPay = GrossPay - TotalDeductions;
print.println("(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)");
print.println("~\tJ&K Enterprises\t\t\tCheck#1 Date: April 13, 2007\t~");
print.println("~\tAP Java Avenue\t\t\t\t\t\t\t~");
print.println("~\tRio Rancho, Nm 87124\t\t\t\t\t\t~");
print.println("~\tPay to the order of: "+name+"\t\t\t\t\t\t~");
print.println("~\tSocial Security#: "+SocialSecurity+"\t\t\t\t\t\t~");
print.println("~\tThe amount of:$ "+fmt.format(NetPay)+"\t\t\t\t\t\t\t~");
print.println("~\t\t\t\t\t\t\tJohn Buric\t~");
print.println("~\t\t\t\t\t\t\tOwner\t\t~");
print.println("(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)");
print.println("~\tTotal Hours Worked: "+TotalHrs+" at $"+HrPay+"per hour");
print.println("~\tRegular Pay: $ "+fmt.format(RegularPay)+"");
print.println("~\tOvertime Pay: $ "+fmt.format(OvertimePay)+"");
print.println("~\t\t\t\t -----------");
print.println("~\tGross Pay: $ "+fmt.format(GrossPay)+"");
print.println("~\tState Tax: $ "+fmt.format(StateTax)+" at "+fmt2.format(StateTaxRate)+" % ");
print.println("~\tFederal Tax: $ "+fmt.format(FederalTax)+" at "+fmt2.format(FederalTaxRate)+" % ");
print.println("~\tTotal Deductions: $ "+fmt.format(TotalDeductions)+"");
print.println("~\tNet Pay: $ "+fmt.format(NetPay)+"");
print.println("(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)(o.O)(O.o)");
}
}
Our output file currently looks like this and only does the rock n roll but doesnt do the other profile, as stated above would we use a for loop to read in other profiles?
//////////////////////////////////////////////////////// /J&K Enterprises Check #1 Date: April 13, 2007 /AP Java Avenue /Rio Rancho, NM 87124 / /Pay to the order of:Rock N Roll /Social Security #:112-23-3445 / /The Amount of:$ 242.38 / / Owner //////////////////////////////////////////////////////// /TotalHours Worked:56 at $ 5.26 per hour /Regular Pay: $ 210.4 /Overtime Pay: $ 126.24 / ------- /Gross Pay: $ 336.64 /State Tax: $ 20.2 at .06% /Federal Tax: $ 74.06 at .22% /Total Deductions: $ 94.26 /Net Pay: $ 242.38 ////////////////////////////////////////////////////////
After this said we need to create 7 functions at least and atleast 1 recursion statement to meet the requirements of the program, thx for your time and any help is appreciated.
O yea we need this by like tommorow lol
This post has been edited by ProGraM: 12 April 2007 - 09:00 AM

New Topic/Question
Reply



MultiQuote



|