Results 1 to 3 of 3
  1. #1
    jvasilj1 is offline Member
    Join Date
    Jan 2008
    Posts
    36
    Rep Power
    0

    Default

    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.");
    }

    }
    }

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    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)

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    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

  1. Welcome to our new forum: Forum Lobby
    By JavaForums in forum Forum Lobby
    Replies: 18
    Last Post: 02-07-2008, 05:40 AM
  2. Move to forum 'New To Java'
    By lalithalydia in forum New To Java
    Replies: 1
    Last Post: 01-31-2008, 07:16 AM
  3. Move to correct forum
    By JavaJunkie1983 in forum Introductions
    Replies: 7
    Last Post: 01-23-2008, 03:04 AM
  4. Move to correct forum...
    By Winarto in forum Introductions
    Replies: 3
    Last Post: 01-18-2008, 03:00 AM
  5. New To Java Forum
    By nani5swamy in forum Introductions
    Replies: 3
    Last Post: 01-04-2008, 03:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •