Results 1 to 3 of 3
Thread: Move to forum 'New To Java'
- 01-29-2008, 08:58 PM #1
Member
- Join Date
- Jan 2008
- Posts
- 36
- Rep Power
- 0
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.");
}
}
}
- 02-02-2008, 08:21 AM #2
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.
Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 02-02-2008, 08:22 AM #3
Please name your threads appropriately as well. Thank you.
Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
Similar Threads
-
Welcome to our new forum: Forum Lobby
By JavaForums in forum Forum LobbyReplies: 18Last Post: 02-07-2008, 05:40 AM -
Move to forum 'New To Java'
By lalithalydia in forum New To JavaReplies: 1Last Post: 01-31-2008, 07:16 AM -
Move to correct forum
By JavaJunkie1983 in forum IntroductionsReplies: 7Last Post: 01-23-2008, 03:04 AM -
Move to correct forum...
By Winarto in forum IntroductionsReplies: 3Last Post: 01-18-2008, 03:00 AM -
New To Java Forum
By nani5swamy in forum IntroductionsReplies: 3Last Post: 01-04-2008, 03:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks