Results 1 to 2 of 2
  1. #1
    PeterFeng is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

    Default How to Write this if statement?

    5X2 table:
    M1 | M2 | M3 | M4 | M5
    MC1|MC2|MC3|MC4|MC5

    I've been thinking for the past 2 hrs. I thought of this, please correct me if i'm wrong;

    mc1 will compare with m1, m2, m3, m4, m5. If none of m1-m5 is bigger than mc1, then mc1 will be put aside into a variable call ma (memory unallocated)

    ignore compareMem1-5 for now. I'm using it to compare which has the largest difference among all of them.

    Java Code:
    if(MC1<M1)
    {
     compareMem1=M1-MC1;
    }
    if(MC1<M2)
    {
     compareMem2=M2-MC1;
    }
    if(MC1<M3)
    {
     compareMem3=M3-MC1;
    }
    if(MC1<M4)
    {
     compareMem4=M4-MC1;
    }
    if(MC1<M5)
    {
     compareMem5=M5-MC1;
    }
    else
    {
     MC1=MA1;
    }
    Last edited by PeterFeng; 01-14-2009 at 07:01 AM.

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Lightbulb directed acyclic graph

    I am still not up to needed skills on this but ( hoping a few comments help ) I bought a two volume set "Algorithms in Java" by Robert Sedgewick, the work is reamarkably well written for understanding and plain language. What you are doing resolves to "Trees" - a common computer science concept. The way you are going about it needs a return statement on each conditional + can be re-thought as putting the values in an array or collection, then writing a for( ; ; ) construct, which as I remember will accept a break; on condition true / false.....many computer science issues here, directed acyclic graph == no shortage of nomenclature or previous work available from the college professors.

    Try the aussie's first, they seem to be better at computer science than anything else I have found.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

Similar Threads

  1. if statement help please!!
    By soc86 in forum New To Java
    Replies: 5
    Last Post: 12-02-2008, 02:56 PM
  2. If statement, please help??
    By soc86 in forum New To Java
    Replies: 5
    Last Post: 11-23-2008, 02:58 PM
  3. Help with if statement
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 07:53 AM
  4. Statement or Prepared Statement ?
    By paty in forum JDBC
    Replies: 3
    Last Post: 08-01-2007, 04:45 PM
  5. If Statement
    By aDrizzle in forum New To Java
    Replies: 4
    Last Post: 07-08-2007, 08:55 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
  •