Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-18-2007, 06:55 PM
Member
 
Join Date: Jul 2007
Posts: 35
silvia is on a distinguished road
Error: unexpected type
Hi, I have tried every way I could think to correct this problem. This is the last of 13 errors I had to find debugging this assignment.

Code:
interest = annualInterest 12;
after compiling it, the error message said:

Code:
possible loss of precision found: double required: int
the declaring variables are

int price, downPayment, tradeIn, months, loanAmt, interest;
double annualInterest, payment;

under conversions there is this:

Code:
annualInterest =Double.parseDouble(inputAnnualInterest);
under calculations the line of code is
Code:
interest = annualInterest 12;
I tried putting "/" in front of 12, got an error. Tried putting parantheses around
(annualInterest 12) got an error. How to get int when there is a double. I determined from declared variable annualInterest was the double. So here is what I tried next:

Code:
interest = (double = (annualInterest / 12));
got an error back
Code:
unexpected type required: variable found : class interest = (double = (annualInterest / 12)); ^(under the d in double) 1 error

My understanding is everything in the ( ) has to equate to an int and not double...since interest is an int. Must be close because the error message no longer says found: double required: int. It just says found:class required variable.

Maybe someone can clarify my understanding.

Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 07:41 AM
Member
 
Join Date: Jul 2007
Posts: 40
barney is on a distinguished road
Code:
interest = annualInterest / 12;
Think to yourself what are you DOING with interest. How do you get it. You weren't really doing anything to it. The interest might be better off as a double. In the future post all of your code.
Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting your own type in a Set Java Tip java.lang 0 04-15-2008 09:32 PM
Type Casting Help rhm54 New To Java 2 02-07-2008 02:06 PM
An unexpected jumper bug on my IO code? cruxblack New To Java 7 07-29-2007 10:24 AM
Error: invalid method declaration; return type required silvia AWT / Swing 1 07-19-2007 03:51 PM
The return type Marcus New To Java 1 07-05-2007 08:28 AM


All times are GMT +3. The time now is 10:12 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org