Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-13-2009, 10:10 PM
Member
 
Join Date: Oct 2008
Posts: 39
Rep Power: 0
soc86 is on a distinguished road
Default casting help
Can someone help with my code, I have been asked to complete this for uni, I have been asked to keep the variables as the following

double wheelRad;
int fSprocket;
int rSprocket;
double eRad;

what is wrong with my code?



public class BicylceGears{

public static void main (String[]args){
//Below I have declared my variables
double wheelRad;
int fSprocket;
int rSprocket;
double eRad;

System.out.println("Please enter the wheel radius");
wheelRad = UserInput.readDouble;

System.out.println("How many teeth are on the front sprocket?");
fSprocket = UserInput.readInt;

System.out.println("How many teeth are on the rear sprocket?");
rSprocket = UserInput.readInt;

eRad = wheelRad*fSprocket/rSprocket;

System.out.println("The effective radius for raduis "+wheelRad+" and sprockets "+fSprocket+" and "+rSprocket+" is " +double eRad+);

}//end main

}//end class
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-13-2009, 10:25 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 3,190
Rep Power: 5
Fubarable is on a distinguished road
Default
what happens wrong when you try to compile or run it? Is it complaining that you're not initializing your variables? If so, then initialize them when you declare them. Instead of
Code:
int fubar;
do
Code:
int fubar = 0;
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-13-2009, 10:26 PM
Member
 
Join Date: Oct 2008
Posts: 39
Rep Power: 0
soc86 is on a distinguished road
Default
.class expected

System.out.println("The effective radius for raduis "+wheelRad+" and sprockets "+fSprocket+" and "+rSprocket+" is " +double eRad+);
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-13-2009, 10:34 PM
Member
 
Join Date: Oct 2008
Posts: 39
Rep Power: 0
soc86 is on a distinguished road
Default
It keeps prompting the following error on the line below:

.class expected

System.out.println("The effective radius for raduis "+wheelRad+" and sprockets "+fSprocket+" and "+rSprocket+" is " +double eRad+);
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-13-2009, 11:07 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 3,190
Rep Power: 5
Fubarable is on a distinguished road
Default
What is UserInput and where do you declare this variable? And you never call any methods on it either (method calls must end in a parenthesis).

You also have an error here:
Code:
+double eRad+);// why do you have double here and the last + sign?

Last edited by Fubarable; 01-13-2009 at 11:10 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
type casting alvations New To Java 1 10-13-2008 07:07 PM
class casting vital parsley New To Java 1 07-24-2008 10:03 AM
Casting problem John_28 New To Java 6 05-14-2008 11:29 AM
Casting an int value into a char kurtulas New To Java 2 02-16-2008 08:03 PM
Casting leebee New To Java 5 08-10-2007 12:24 PM


All times are GMT +2. The time now is 05:36 PM.



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