473,408 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Need Help W/ Writing a Program

6
I have tried all I know and still continue to get errors in my program can any one give me some guidance? I would be grateful. What I wrote is:

import java.text.*;// For using DecimalFormat class for 2 decimal places
import java.util.*;// For using Scanner class for input

public class Tax
{
public static void main(String [] args)
{
Scanner key = new Scanner(System.in);
DecimalFormat twoDec = new DecimalFormat("$0.00");
Taxable income = 0.0, Tax payable = 0.0;
System.out.print("Enter Taxable income ($): \t");
Taxable income = Key.nextDouble();
if (Taxable income < 1.00)
{
System.out.print("Error: Taxable income cannot be less than 1.00");
}
else
{
if (Taxable income <= 4461.99)
{
Tax payable = 0.00 * 4461.99;
}
else if (Taxable income <= 17893.99)
{
Tax payable = 0.30 * 17894.00;
}
else if (Taxable income <= 29499.99)
{
Tax payable = 4119.00 && 0.35 * 17894.00;
}
else if (Taxable income <= 45787.99)
{
Tax payable = 8656.00 && 0.46 * 29500.00;
}
else
{
Tax payable = 11179.00 && 0.60 * 45788.00
}
System.out.println("Enter Taxable income:");
System.out.println("0.99");
System.out.println("Taxable income:0.99");
System.out.println("Error: Taxable income cannot be less than 1.00");
}
}



The errors I get is:

';' expected
not a statement
'else' without 'if'
illegal start of type
<identifier> expected
class, interface, or enum expected
Oct 4 '07 #1
7 1418
dmjpro
2,476 2GB
Most probably...

1.
Expand|Select|Wrap|Line Numbers
  1. //Taxable income = 0.0, Tax payable = 0.0;......wrong
  2. Taxable income = 0.0;
  3. Tax payable = 0.0;
  4.  
2.
Expand|Select|Wrap|Line Numbers
  1. //if(Taxable income < 1.00)  ........... this type of expression will be
  2. if(income < 1.00)
  3.  
3.
One "}" is missing.
Most probably it will be just after the last "else block" finishes.

Debasis Jana
Oct 4 '07 #2
madhoriya22
252 100+
I have tried all I know and still continue to get errors in my program can any one give me some guidance? I would be grateful. What I wrote is:

import java.text.*;// For using DecimalFormat class for 2 decimal places
import java.util.*;// For using Scanner class for input

public class Tax
{
public static void main(String [] args)
{
Scanner key = new Scanner(System.in);
DecimalFormat twoDec = new DecimalFormat("$0.00");
Taxable income = 0.0, Tax payable = 0.0;
System.out.print("Enter Taxable income ($): \t");
Taxable income = Key.nextDouble();
if (Taxable income < 1.00)
{
System.out.print("Error: Taxable income cannot be less than 1.00");
}
else
{
if (Taxable income <= 4461.99)
{
Tax payable = 0.00 * 4461.99;
}
else if (Taxable income <= 17893.99)
{
Tax payable = 0.30 * 17894.00;
}
else if (Taxable income <= 29499.99)
{
Tax payable = 4119.00 && 0.35 * 17894.00;
}
else if (Taxable income <= 45787.99)
{
Tax payable = 8656.00 && 0.46 * 29500.00;
}
else
{
Tax payable = 11179.00 && 0.60 * 45788.00
}
System.out.println("Enter Taxable income:");
System.out.println("0.99");
System.out.println("Taxable income:0.99");
System.out.println("Error: Taxable income cannot be less than 1.00");
}
}



The errors I get is:

';' expected
not a statement
'else' without 'if'
illegal start of type
<identifier> expected
class, interface, or enum expected
Hi,
Can u explain me what is this ..
Expand|Select|Wrap|Line Numbers
  1. Taxable income = 0.0, Tax payable = 0.0;
  2.  
If these are variables u r declaring .. then this way of declaring variables is completely wrong. You can't provide spaces while declaring variables. Even you hav not provided the type of variables.
Oct 4 '07 #3
Levar
6
Debasis Jana,

Thank you so very much for the guidance it helped greatly. Could you give me another tip please? I have two errors now after following what you mention. One is this line:

Tax payable = 11179.00 && 0.60 * 45788.00

and the error is:

';' expected


the other is this line:

}

and the error is:

reached end of file while parsing

if you can help Thank you if not still Thank you!






Most probably...

1.
Expand|Select|Wrap|Line Numbers
  1. //Taxable income = 0.0, Tax payable = 0.0;......wrong
  2. Taxable income = 0.0;
  3. Tax payable = 0.0;
  4.  
2.
Expand|Select|Wrap|Line Numbers
  1. //if(Taxable income < 1.00)  ........... this type of expression will be
  2. if(income < 1.00)
  3.  
3.
One "}" is missing.
Most probably it will be just after the last "else block" finishes.

Debasis Jana
Oct 4 '07 #4
dmjpro
2,476 2GB
What does it mean ...

"Tax payable = 11179.00 && 0.60 * 45788.00"
What do you want to do here?

And post me d full code with code tags what you changed.

Debasis Jana
Oct 4 '07 #5
Levar
6
This is what I have now:



import java.text.*;// For using DecimalFormat class for 2 decimal places
import java.util.*;// For using Scanner class for input

public class Tax
{
public static void main(String [] args)
{
Scanner key = new Scanner(System.in);
DecimalFormat twoDec = new DecimalFormat("$0.00");
Taxable income = 0.0;
Tax payable = 0.0;
System.out.print("Enter Taxable income ($): \t");
Taxable income = Key.nextDouble();
if (income < 1.00)
{
System.out.print("Error: Taxable income cannot be less than 1.00");
}
else
{
if (income <= 4461.99)
{
Tax payable = 0.00 * 4461.99;
}
else if (income <= 17893.99)
{
Tax payable = 0.30 * 17894.00;
}
else if (income <= 29499.99)
{
Tax payable = 4119.00 && 0.35 * 17894.00;
}
else if (income <= 45787.99)
{
Tax payable = 8656.00 && 0.46 * 29500.00;
}
else
{
Tax payable = 11179.00 && 0.60 * 45788.00;
}
System.out.println("Enter Taxable income:");
System.out.println("0.99");
System.out.println("Taxable income:0.99");
System.out.println("Error: Taxable income cannot be less than 1.00");
}
}




And I would the only problem now is the last line it is giving me the error:

reached end of file while parsing

and I don't know why
Oct 4 '07 #6
JosAH
11,448 Expert 8TB
The errors I get is:

';' expected
not a statement
'else' without 'if'
illegal start of type
<identifier> expected
class, interface, or enum expected
That was not what you saw after compilation. The compiler showed you line numbers
and the exact position on the line where it found the mistake. You don't want us
to start guessing do you? You should show us what you saw verbatim. Computer
programming languages are not about vague guesses or whatever; programming
is about as much information you can supply, either the computer itself (it did
supply as much information), or you, when you pass those error diagnostics to us.

kind regards,

Jos
Oct 4 '07 #7
r035198x
13,262 8TB
Please do not post the same code over and over again.
And if you really have to post code, post only the relevant parts and use code tags.
You have some illegal statements in your code. Refer to your textbook on operators and how to use them legally in Java.
Oct 4 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
13
by: Heather Stovold | last post by:
Wow - deciding to program in python sure requires a lot of decisions! So far: I've decided on python for the programming language. I've decided on wxpython for the GUI.... I've decided on...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
13
by: vgame64 | last post by:
Hi, I have been struggling with writing a program for a few hours. The requirements are that: """You will be writing a program which will determine whether a date is valid in terms of days in that...
12
by: asif929 | last post by:
I am trying to write a program which creates four triangles. The program begins with prompting a user " Enter the size of triangles", number from 1 to N is the size of four triangles For Example if...
0
by: RENEE | last post by:
I Need help writing a program that will process payroll for small company with 26 employess, needs to store all employee name in sequential file along with address info, pay rate, number of...
1
by: lenest | last post by:
I need help writing a program.... You are to write a python program to accomplish the following: a.. Play a dice game of Craps using a random number generator to simulate the roll of the...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
7
by: rohitsripathi | last post by:
i need help writing this program... i am in college and i do not have time do this right now as i need to study for another test....but this is due tonight...i will pay $5 if you accept to do it and...
5
by: alck1234 | last post by:
Hi, I need help on my mini project on object orientated programming. The question goes like this: A mini-mart has just installed a bar code reader to improve efficiency at their checkouts....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.