Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 8th, 2004, 08:11 PM
tootall2 tootall2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 tootall2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Compiler error Please Help

Can someone please help me with this compiler error. java:28: operator * cannot be applied to int,java.lang.String
StateTaxDue = 0.03 * incomeValue - (600 * dependents);

The program is:
import java.io.*;
import javax.swing.JOptionPane;
public class StateTax
{
public static void main(String[] args) throws IOException
{
BufferedReader inData;
inData = new BufferedReader(new InputStreamReader(System.in));

//declaring Variables
String income, dependents;
int StateTaxDue;
int incomeValue = Integer.parseInt(income);
int dependentsValue = Integer.parseInt(dependents);

//user input
System.out.println("State Tax Computation");
income = JOptionPane.showInputDialog(null, "Taxpayers Income:");
dependents = JOptionPane.showInputDialog(null, "Number Of Dependents:");

//Conversions
StateTaxDue = 0.03 * incomeValue - (600 * dependents);

//output
JOptionPane.showMessageDialog(null, "State Tax Due:" + StateTaxDue);
System.exit(0);


}
}

Reply With Quote
  #2  
Old October 10th, 2004, 07:59 AM
gertcuppens's Avatar
gertcuppens gertcuppens is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 118 gertcuppens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 28 m
Reputation Power: 5
At first, I don't see the error. Could it be that 0.03 should be written as .03 ?
But since you're working with 2 constants, you could declare them at the beginning of you class,
like this
protectedfinal int PERCENTAGE = .03;

This way, if your class should become quite large, you have an overview of all
constants at the beginning of the class.



Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Compiler error Please Help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT