) needed, syntax error help
import java.io.*;
import java.util.*;
publicclass Salary
{
publicstaticvoid main (String[] args)
throws FileNotFoundException
{
PrintWriter outFile =new PrintWriter("everydayimhustling.txt");
int bonus;
int additionalBonus;
Scanner console =new Scanner(System.in);
System.out.println("Enter Your Base Salary:");
double baseSalary = console.nextDouble();
System.out.println("Enter Number of Service Years:");
double noOfYears = console.nextDouble();
System.out.println("Enter Your Total Amount of Sales:");
double totalSale = console.nextDouble();
if (noOfYears <= 5)
bonus = 10 * noOfYears;
else
bonus = 20 * noOfYears;
if (totalSale < 5000)
additionalBonus = 0;
else
if (totalSale >= 5000 and totalSale < 10000)//HERE IS THE PROBLEM
additionalBonus = totalSale * (0.03);
else
additionalBonus = totalSale * (0.06);
outFile.close();
}
}
any help would be greatly appreciated.
[2015 byte] By [
nsfoura] at [2007-11-27 2:56:09]

wait theres more errors:
import java.io.*;
import java.util.*;
public class Salary
{
public static void main (String[] args)
throws FileNotFoundException
{
PrintWriter outFile = new PrintWriter("everydayimhustling.txt");
int bonus;
int additionalBonus;
int payCheck;
Scanner console = new Scanner(System.in);
System.out.println("Enter Your Base Salary:");
double baseSalary = console.nextDouble();
System.out.println("Enter Number of Service Years:");
double noOfYears = console.nextDouble();
System.out.println("Enter Your Total Amount of Sales:");
double totalSale = console.nextDouble();
if (noOfYears <= 5)
bonus = 10 * noOfYears;//POSSIBLE LOSS OF PRECISION
else
bonus = 20 * noOfYears;
if (totalSale < 5000)
additionalBonus = 0;
else
if (totalSale >= 5000 && totalSale < 10000)
additionalBonus = totalSale * (0.03);
else
additionalBonus = totalSale * (0.06);
payCheck = baseSalary + bonus + additionalBonus;
outFile.printf("Base Salary: " + baseSalary);//HOW DO YOU PAGEBREAK THIS OUT IN THE TEXT FILE
outFile.printf("Years of Service: " + noOfYears);
outFile.printf("Amount of Sales: " + totalSale);
outFile.printf("Paycheck: " + payCheck);
System.out.println("Look in everydayimhustling.txt for Paycheck Amount");
outFile.close();
}
}
thanks:
pbrockway2
prometheuzz
AnanSmriti
!! i appreciate your help.
a few more OCD details though... =]
>>Base Salary: 1.0E7Years of Service: 6.0Amount of Sales: 20000.0Paycheck: 1.000132E7<<
is the output file..
i tried making them long, however, i still got loss of precision..
also, how do i make the output look like this:
Base Salary: 1.0E7
Years of Service: 6.0
Amount of Sales: 20000.0
Paycheck: 1.000132E7
outFile.println("Base Salary: " + baseSalary);
outFile.println("Years of Service: " + noOfYears);
outFile.println("Amount of Sales: " + totalSale);
outFile.println("Paycheck: " + payCheck);
change your int to double. it will help you avoid loss of precision