Thread: Help with If's.

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    1
    Rep Power
    0

    Help with If's.


    Help is greatly appreciated. Thanks in advance.

    I am having trouble with the if's.

    I have attached the .java along with this post. Please take a min to check it out. THanks. my msn
    neolankan@hotmail.com
    Attached Files
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Cambs, UK
    Posts
    68
    Rep Power
    13
    Just add some brackets {} and the compilation errors go.

    Code:
    //DECIDE WHAT REMARK TO PRINT ON RECEIPT
    if (gpa <=39) {
      //remark = "  You are a good customer   ";
    } else if (gpa <= 40) {
      System.out.print (" WoW...Java Jake's Loves You");
      //remark = " WoW...Java Jake's Loves You";
    } else if (gpa <= 60) {
      System.out.print (" 60");
      // remark = " 60-69";
    } else if (gpa <= 70) {
      System.out.print (" 70");
      // remark = " 70-79";
    } else {
      System.out.print (" Error ");
    }

    Either that or uncomment the line 'remark = "You are a good customer"'

    Code:
    //DECIDE WHAT REMARK TO PRINT ON RECEIPT
    if (gpa <=39)
      // Need something other than a comment here!
      remark = "  You are a good customer   ";
    else if (gpa <= 40)
      System.out.print (" WoW...Java Jake's Loves You");
      //remark = " WoW...Java Jake's Loves You";
    else if (gpa <= 60)
      System.out.print (" 60");
      // remark = " 60-69";
    else if (gpa <= 70)
      System.out.print (" 70");
      // remark = " 70-79";
    else
      System.out.print (" Error ");

    But it's better practice to include the brackets.
    Last edited by LTheobald; March 5th, 2003 at 05:05 AM.

IMN logo majestic logo threadwatch logo seochat tools logo