Help in java pograming

hello i am new to java pograming and i am trying to Write a program that calculates and prints the monthly paycheck for an employee, where the net pay is calculated after removing deductions for taxes, health insurance, and a retirement plan.

A federal income tax rate of 15%

A state income tax rate of 3.5%

A Social Security tax rate of 5.75%

A Medicare/Medicaid tax rate of 2.75%

A retirement plan contribution rate of 5%, and

A health insurance premium of $75.00

i have done this much but still getting errors and i can't figer out wat am i doing wrong here is the code what i have done

import java.util.Scanner;

publicclass Assignment_3

{

publicstaticvoid main(String[] args)

{

// Defining Strings int double and scanner

String FName, LName;

int SSN;

double Gross_Salary, Fedral_IncomeTax, State_IncomeTax,

Social_SecurityTax, Medicare_Tax, Retirement_Plan, Net_Salary ;

Scanner input =new Scanner(System.in);

// Taking input from the user. First Name, Last Name SSN and Monthly

Salary in dollars

System.out.print("Enter your First Name: " );

FName = input.next();

System.out.print("Enter your Last Name: " );

LName = input.next();

System.out.println();

System.out.print("Enter your Social Security Number: " );

SSN = input.nextInt();

System.out.print("Enter your Gross Monthly Salary ($) without decudtion of taxes: " );

Gross_Salary = input.nextDouble();

//Calculating the taxes owed

Fedral_IncomeTax = Gross_Salary * (15.0/100);

State_IncomeTax = Gross_Salary * (3.5/100);

Social_SecurityTax = Gross_Salary * (5.75/100);

Medicare_Tax = Gross_Salary * (2.75/100);

Retirement_Plan = Gross_Salary * (5.0/100);

finaldouble Health_Insurance = 75.00;

Net_Salary = Gross_Salary - Fedral_IncomeTax - State_IncomeTax -

Social_SecurityTax - Medicare_Tax - Retirement_Plan - Health_Insurance;

// Outputting the values calculated

System.out.println("\n");

System.out.printf("The Fedral Income Tax is($): %.2f\n",

Fedral_IncomeTax);

System.out.printf("The State Income Tax is($): %.2f\n",

State_IncomeTax);

System.out.printf("The Social Security Tax is($): %.2f\n",

Social_SecurityTax);

System.out.printf("The Medicare/Medicaid Taxes is($): %.2f\n",

Medicare_Tax);

System.out.printf("The Retirement Contribution is($): %.2f\n",

Retirement_Plan);

System.out.printf("The Health Insurance Premium is($): %.2f\n\n",

Health_Insurance);

System.out.printf("The Net Salary of " + FName +" " + LName +" is:

%.2f\n", Net_Salary);

}

}

[3766 byte] By [nish130a] at [2007-11-27 2:22:19]
# 1
What errors are you getting?
tsitha at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 2

i am getting six errors its says

C:\Documents and Settings\Owner\Desktop\homework3.java:27: ';' expected

Salary in dollars

^

C:\Documents and Settings\Owner\Desktop\homework3.java:28: ';' expected

System.out.print("Enter your First Name: " );

^

C:\Documents and Settings\Owner\Desktop\homework3.java:64: unclosed string literal

System.out.printf("The Net Salary of " + FName + " " + LName + " is:

^

C:\Documents and Settings\Owner\Desktop\homework3.java:65: illegal character: \92

%.2f\n", Net_Salary);

^

C:\Documents and Settings\Owner\Desktop\homework3.java:65: unclosed string literal

%.2f\n", Net_Salary);

^

C:\Documents and Settings\Owner\Desktop\homework3.java:65: not a statement

%.2f\n", Net_Salary);

^

nish130a at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 3

C:\Documents and Settings\Owner\Desktop\homework3.java:27: ';' expected

Salary in dollars

Salary in dollars is not a statement. I think you forgot to comment that.

C:\Documents and Settings\Owner\Desktop\homework3.java:28: ';' expected

System.out.print("Enter your First Name: " );

If I'm not mistaken, fixing the first problem should fix this.

C:\Documents and Settings\Owner\Desktop\homework3.java:64: unclosed string literal

System.out.printf("The Net Salary of " + FName + " " + LName + " is:

You have an open quotation mark at the end.

C:\Documents and Settings\Owner\Desktop\homework3.java:65: illegal character: \92

%.2f\n", Net_Salary);

^

C:\Documents and Settings\Owner\Desktop\homework3.java:65: unclosed string literal

%.2f\n", Net_Salary);

^

C:\Documents and Settings\Owner\Desktop\homework3.java:65: not a statement

%.2f\n", Net_Salary);

You have not included this part of your code. However, it looks like you need quotation marks around a String somewhere.

Djaunla at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 4

[snip]

> uments and Settings\Owner\Desktop\homework3.java:65:

> not a statement

> %.2f\n", Net_Salary);

>

> You have not included this part of your code.

> However, it looks like you need quotation marks

> around a String somewhere.

well. line 65 is this one:System.out.printf("The Net Salary of " + FName + " " + LName + " is:

%.2f\n", Net_Salary);

where it looks like a newline was inserted after the "is: - change it to System.out.printf("The Net Salary of " + FName + " " + LName + " is: " +

"%.2f\n", Net_Salary);

tsitha at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 5
QuestionWhat does Salary in dollars do?
SandyReda at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 6

did you do a return on

System.out.printf("The Net Salary of " + FName + " " + LName + " is: " +

"%.2f\n", Net_Salary);

of is it a wrap text.

When I did a test on this I got a error at that spot as well I then did a backspac on "%.2f\n", Net_Salary);

and it took the error away.

Message was edited by:

SandyRed

SandyReda at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 7
oh yeah u r right i fogot to do the "%.2f\n", Net_Salary); wrap text that's why thanks
nish130a at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 8
its a number of constants to represent the various percentages and dollar amounts that are used to compute the net pay
nish130a at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 9

i am still getting the error

C:\Documents and Settings\Owner\Desktop\homework3.java:27: ';' expected

Salary in dollars

^

C:\Documents and Settings\Owner\Desktop\homework3.java:28: ';' expected

System.out.print("Enter your First Name: " );

as someone meantion before that its an not a statment i still don't understand kind of confuse about it

nish130a at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 10
you're welcome. Boy it feels good to help someone, I finally was able to return it...I'm also very new to Java I have only done 4 projects.sandyRGood luck in learn Java
SandyReda at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 11

This:

// Taking input from the user. First Name, Last Name SSN and Monthly

Salary in dollars

Should be:

// Taking input from the user. First Name, Last Name SSN and Monthly

// Salary in dollars

or

// Taking input from the user. First Name, Last Name SSN and Monthly Salary in dollars

abillconsla at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 12
thanks a lot yes its very very confusing thanks a lot for help
nish130a at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 13
ohhhhhh thanks abillconsl for help
nish130a at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 14
Sure thing. For the record. /* ... */ designate what could be a multi-line comment; whereas // is one line only.
abillconsla at 2007-7-12 2:26:19 > top of Java-index,Java Essentials,Java Programming...
# 15

That's one of the first question I asked you.

All well at least you got it now....

sandyR

ps try not to do a hard turn when you're writting your code of lines, just let it wrap.

you know what I mean....

Message was edited by:

SandyRed

Message was edited by:

SandyRed

SandyReda at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 16
Thanks guys *~*
nish130a at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 17
You are welcome. You will distribute the [url #" style="display: block; background-image:url(' http://developers.sun.com/forums/img/gold-star.gif'); width: 17px; height: 17px] [/url] to those who helped?Message was edited by: abillconsl
abillconsla at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 18
No, you won't?
abillconsla at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 19

Greetings,

I too am required to write a program to this effect, although my errors are coming up a bit differently than the OP.

If anyone can lend some insight to these errors I would great appreciate it.

Below is the actual syntax, followed by the errors I am receiving.

Thank you in advance.

Jennifer Wood

import java.lang.*;

import java.util.Scanner;

public class Monthly_Paycheck

{

public static void main(String[] args)

{

//declares and initializes variables

double Gross;

double SSN;

double rate;

double Fed_Tax;

double State_Tax;

double Medi;

double Pension;

final double Health_Ins;

double Net;

String FName;

String LName;

Scanner input = new Scanner(System.in);

//Input from the user

System.out.print("Enter First Name: ");

FName = input.next();

System.out.print("Enter Last Name: ");

LName = input.next();

System.out.print("Enter your Gross Salary: ");

Gross = input.nextDouble();

//Calculations

Fed_Tax = Gross * (15.00/100);

State_Tax = Gross * (3.5/100);

SSN = Gross * (5.75/100);

Medi = Gross * (2.75/100);

Pension = Gross * (5.0/100);

Health_Ins = 75.00;

Net = Gross - Fed_Tax - State_Tax - SSN - Medi - Pension - Health_Ins;

//Output response

System.out.printf("Federal Income Tax Deduction = %.2f\n", Fed_Tax);

System.out.printf("State Income Tax Deducation = %.2f\n", State_Tax);

System.out.printf("Social Security Tax Deduction = %.2f\n", SSN);

System.out.printf("Medicare/Medicaid Tax Deduction = %.2f\n", Medi);

System.out.printf("Pension Deduction = %.2f\n", Pension);

System.out.printf("Health Insurance Deduction = %.2\n", Health_Ins);

System.out.printf("The Net Salary after all deductions for " + FName + " " + LName + "is: %.2f\n", Net);

}

}

ERRORS:

Enter First Name: Jennifer

Enter Last Name: Wood

Enter your Gross Salary: 5000

Federal Income Tax Deduction = 750.00

State Income Tax Deducation = 175.00

Social Security Tax Deduction = 287.50

Medicare/Medicaid Tax Deduction = 137.50

Pension Deduction = 250.00

Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '.'

at java.util.Formatter.checkText(Formatter.java:2500)

at java.util.Formatter.parse(Formatter.java:2482)

at java.util.Formatter.format(Formatter.java:2411)

at java.io.PrintStream.format(PrintStream.java:899)

at java.io.PrintStream.printf(PrintStream.java:800)

at Monthly_Paycheck.main(Monthly_Paycheck.java:45)

Jennifer_Wooda at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 20

> Greetings,

>

> I too am required to write a program to this effect,

> although my errors are coming up a bit differently

> than the OP.

>

> If anyone can lend some insight to these errors I

> would great appreciate it.

>

> Below is the actual syntax, followed by the errors I

> am receiving.

>

> Thank you in advance.

>

> Jennifer Wood

>

> import java.lang.*;

> import java.util.Scanner;

>

> public class Monthly_Paycheck

> {

> public static void main(String[] args)

> {

> //declares and initializes variables

> double Gross;

> double SSN;

> double rate;

> double Fed_Tax;

> double State_Tax;

> double Medi;

> double Pension;

> final double Health_Ins;

> double Net;

> String FName;

> String LName;

> Scanner input = new Scanner(System.in);

>

> //Input from the user

> System.out.print("Enter First Name: ");

> FName = input.next();

> System.out.print("Enter Last Name: ");

> LName = input.next();

> System.out.print("Enter your Gross Salary: ");

> Gross = input.nextDouble();

>

> //Calculations

> Fed_Tax = Gross * (15.00/100);

> State_Tax = Gross * (3.5/100);

> SSN = Gross * (5.75/100);

> Medi = Gross * (2.75/100);

> Pension = Gross * (5.0/100);

> Health_Ins = 75.00;

> Net = Gross - Fed_Tax - State_Tax - SSN - Medi -

> - Pension - Health_Ins;

>

> //Output response

> System.out.printf("Federal Income Tax Deduction =

> = %.2f\n", Fed_Tax);

> System.out.printf("State Income Tax Deducation =

> = %.2f\n", State_Tax);

> System.out.printf("Social Security Tax Deduction =

> = %.2f\n", SSN);

> System.out.printf("Medicare/Medicaid Tax Deduction =

> = %.2f\n", Medi);

> System.out.printf("Pension Deduction = %.2f\n",

> , Pension);

> System.out.printf("Health Insurance Deduction =

> = %.2\n", Health_Ins);

> System.out.printf("The Net Salary after all

> l deductions for " + FName + " " + LName + "is:

> %.2f\n", Net);

> }

> }

>

>

> ERRORS:

> Enter First Name: Jennifer

> Enter Last Name: Wood

> Enter your Gross Salary: 5000

> Federal Income Tax Deduction = 750.00

> State Income Tax Deducation = 175.00

> Social Security Tax Deduction = 287.50

> Medicare/Medicaid Tax Deduction = 137.50

> Pension Deduction = 250.00

> Exception in thread "main"

> java.util.UnknownFormatConversionException:

> Conversion = '.'

> at

> t java.util.Formatter.checkText(Formatter.java:2500)

> at java.util.Formatter.parse(Formatter.java:2482)

> at java.util.Formatter.format(Formatter.java:2411)

> at java.io.PrintStream.format(PrintStream.java:899)

> at java.io.PrintStream.printf(PrintStream.java:800)

> at Monthly_Paycheck.main(Monthly_Paycheck.java:45)

You are missing f in the formating in your second last statement. It should be:

System.out.printf("Health Insurance Deduction = %.2f\n", Health_Ins);

DarumAa at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 21

Thank you.

I recently re-read my problem and found I have to print to a file as well. (I thought they just mean to the screen, but then I turned the page over and found the rest of the instructions.)

Can you lend any insight to this?

http://forum.java.sun.com/thread.jspa?threadID=5190879

Thank you again!

Jenny

Jennifer_Wooda at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 22
Update:I solved the problem.Thanks for the help!
Jennifer_Wooda at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 23
title says it all :-/
Comp-Freaka at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 24
Yeah I didn't make this thread, just happen to pertain to what I needed.Correct Spelling = Supreme :))
Jennifer_Wooda at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...
# 25
> Yeah I didn't make this thread, just happen to> pertain to what I needed.In future then it would be a good idea to start your own instead of resurrecting an old one.
floundera at 2007-7-21 20:26:08 > top of Java-index,Java Essentials,Java Programming...