Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
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 01-29-2008, 09:58 PM
Member
 
Join Date: Jan 2008
Posts: 26
jvasilj1 is on a distinguished road
can someone help me Im having trouble with my assingment, we have to debug two java programs and get them to be able to compile...they are still giving me errors. can somone help me see what im missing. here are the codes.

// Convert from Meters to Feet and Inches
The program should repeatedly input a length in meters
and then print that length in feet and inches.

private class MeterToFtIn
{
public static void main(String[ ] argv)
{
double meter, f, i;
int more;
Scanner console = new Scanner(System.in);

System.out.print("Do you wish to input another length in meters: ");
more = con.nextInt( );
more = more.toUpperCase( );
while(more.charAt(0) = 'Y')
{
System.out.print('Enter length in meters: ');
meter = con.nextDouble( );
f = meter * 3.28083989501312;
feet = (int) f;
inches = (int) (12 * (feet - f) + 0.5);

System.out.print("The length is ");
if (feet == 1)
System.out.print(feet + "foot ");
else
System.out.print(feet + "feet ");
if (inches == 1)
System.out.println(inches + " inch.");
else if (inches < 1)
System.out.println(inches + " inches.");
else
System.out.println(".");

System.out.print(
"Do you wish to input another length in meters: ");
more = con.next( );
more = more.toUpperCase;
}
}
}

--------------------------------------------------------
heres the second one


// Check to see if an input string is a palindrome

// orig is the original string,
// processed is the string after removing all characters
/ that are not letters and converting to upper case.

Public class PalindromeCheck
{
private static void main(String argv)
{
string orig, processed, letter;
int left, right;
Scanner con = new Scanner(System.out);

System.out.println("Enter a string:");
orig = con.next;
for(i = 0; i < orig.length( ); i++)
{
letter = orig.charAt(i);
if (Character.isLetter(letter))
processed += Character.toUpperCase( );
}

if (processed.length( ) < 0)
{
left = 0;
right = processed.length( );
while (left < right)
{
if (processed.charAt(left) != processed.charAt(right))
System.out.println("String is not a palindrome.");
else
System.out.println("String is a palindrome.");

left++;
right--;
}
System.out.println("String is a palindrome.");
}

}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-02-2008, 09:21 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Debugging and being able to compile are two separate things. The first is used to describe logic issues presently in your code, while the latter concerns a lot of syntax problems. Your problem is closely related to the latter. Start small and see where it takes you.. maybe adding an import or two, confirming that variables are correctly named etc.. You can do this.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-02-2008, 09:22 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Please name your threads appropriately as well. Thank you.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
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
Welcome to our new forum: Forum Lobby JavaForums Forum Lobby 18 02-07-2008 06:40 AM
Move to forum 'New To Java' lalithalydia New To Java 1 01-31-2008 08:16 AM
Move to correct forum JavaJunkie1983 Introductions 7 01-23-2008 04:04 AM
Move to correct forum... Winarto Introductions 3 01-18-2008 04:00 AM
New To Java Forum nani5swamy Introductions 3 01-04-2008 04:54 PM


All times are GMT +3. The time now is 02:47 PM.


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