) 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]
# 1
and == &&
prometheuzza at 2007-7-12 3:33:35 > top of Java-index,Java Essentials,Java Programming...
# 2

And please use brackets!

if(boolean) {

// ...

}

else {

if(boolean) {

// ...

}

else {

// ...

}

}

prometheuzza at 2007-7-12 3:33:35 > top of Java-index,Java Essentials,Java Programming...
# 3

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();

}

}

nsfoura at 2007-7-12 3:33:35 > top of Java-index,Java Essentials,Java Programming...
# 4
&& http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op2.html&& http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter02/operators.html
pbrockway2a at 2007-7-12 3:33:35 > top of Java-index,Java Essentials,Java Programming...
# 5
Your bonus should be double in order to avoid possible loss of precision.
AnanSmritia at 2007-7-12 3:33:35 > top of Java-index,Java Essentials,Java Programming...
# 6

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

nsfoura at 2007-7-12 3:33:35 > top of Java-index,Java Essentials,Java Programming...
# 7

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

AnanSmritia at 2007-7-12 3:33:35 > top of Java-index,Java Essentials,Java Programming...
# 8
outFile.println("Base Salary: " + baseSalary);// oroutFile.printf("Base Salary:%.2f%n", baseSalary);
pbrockway2a at 2007-7-12 3:33:36 > top of Java-index,Java Essentials,Java Programming...
# 9
i changed them all to doubles and tried long to avoid 'scientific' notation, but still got loss of precision..also, how do you make thos println's on seperate lines?
nsfoura at 2007-7-12 3:33:36 > top of Java-index,Java Essentials,Java Programming...
# 10
thank you!!1
nsfoura at 2007-7-12 3:33:36 > top of Java-index,Java Essentials,Java Programming...