I need help on my first JAVA program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RawrSaysI
    New Member
    • Feb 2006
    • 2

    #1

    I need help on my first JAVA program

    I am taking a class on JAVA this semester and was given my first assignment this week. But I am getting an error and I can't figure out what is causing it.

    here is my code:

    public class ShowOperations
    {
    public static void main(String [] args)
    {
    System.out.prin tln("The total of 3 * 5 is " + (3 * 5) + '\n'
    + "The total of 7.1 * 8.3 - 2.2 is " + (7.1 * 8.3 - 2.2) + '\n'
    + "The total of 3.2 / (6.1 * 5) is " + (3.2 / (6.1 * 5)) + '\n'
    + "The total of 15 / 4 is " + (15 / 4) + '\n'
    + "The total of 15% of 4 is " + (15 % 4) + '\n'
    + "The total of 5 * 3 - (6 * 4) is " (5 * 3 - (6 * 4)) + '\n' );
    }
    }

    The error is saying it was expecting a ')' before the last equation but it looks fine to me. All the '(' have closing ')'

    am I making a noob mistake somewhere?
  • RawrSaysI
    New Member
    • Feb 2006
    • 2

    #2
    nevermind i figured it out...i was missing a + before my last equation. gosh its always the simplest thing.

    Comment

    • Niheel
      Recognized Expert Moderator Top Contributor
      • Jul 2005
      • 2433

      #3
      Yes those little mistakes make programming really fun!
      niheel @ bytes

      Comment

      • nixonsun
        New Member
        • Feb 2006
        • 3

        #4
        You missed a + in the last line:
        + "The total of 5 * 3 - (6 * 4) is " + (5 * 3 - (6 * 4)) + '\n' );

        Originally posted by RawrSaysI
        I am taking a class on JAVA this semester and was given my first assignment this week. But I am getting an error and I can't figure out what is causing it.

        here is my code:

        public class ShowOperations
        {
        public static void main(String [] args)
        {
        System.out.prin tln("The total of 3 * 5 is " + (3 * 5) + '\n'
        + "The total of 7.1 * 8.3 - 2.2 is " + (7.1 * 8.3 - 2.2) + '\n'
        + "The total of 3.2 / (6.1 * 5) is " + (3.2 / (6.1 * 5)) + '\n'
        + "The total of 15 / 4 is " + (15 / 4) + '\n'
        + "The total of 15% of 4 is " + (15 % 4) + '\n'
        + "The total of 5 * 3 - (6 * 4) is " (5 * 3 - (6 * 4)) + '\n' );
        }
        }

        The error is saying it was expecting a ')' before the last equation but it looks fine to me. All the '(' have closing ')'

        am I making a noob mistake somewhere?

        Comment

        Working...