The Five Biggest Contradictions in Fitness
Latest Article

The Five Biggest Contradictions in Fitness

Itís no secret that when people contradict themselves, it has the effect of making the flaws in their actions or statements seem glaringly obvious. But what about when WE ourselves get caught contradicting ourselves by someone else?

By: Nick Tumminello Added: January 6th, 2014
More Recent Articles
Contrast Training for Size
By: Lee Boyce
An Interview with Marianne Kane of Girls Gone Strong
By: Jordan Syatt
What Supplements Should I be Taking? By: Jay Wainwright
Bench Like a Girl By: Julia Ladewski
Some Thoughts on Building a Big Pull By: Christopher Mason

Facebook Join Facebook Group       Twitter Follow on Twitter       rss Subscribe via RSS
Results 1 to 15 of 15

Thread: Java Help

  1. #1
    Wannabebig Member
    Join Date
    Feb 2004
    Posts
    9

    Java Help

    I have these extra credit java questions to do and i'm completely clueless. They look like this...

    a. Write a main method to let a user enter student scores, and display the max, min, and average of the score. The input 0 signifies the end of input.

    b. Write a method to find the max in an array of double values. The method signature is as follows:
    public state double max(double[] a)

    c. Write a method to find the max in an array of two-dimensional array of double values. The method signature is as follows:
    public static double max(double [][] a)

    I've searched the net but couldn't find any helpful sites, just a lot of commercial sites wanting you to download something. Does anyone know any good instructional java sites? Any help is appreciated.

    TheOne

  2.    Support Wannabebig and use AtLarge Nutrition Supplements!


  3. #2
    One crazy MOFO/Mail man
    Join Date
    Sep 2002
    Location
    T dot
    Posts
    2,295
    PM me... I'll get back to you in like maybe 2 days.. I got a hardware exam tommorrow morning... But those are easy should take you only maybe a max of 20 mins to do.
    w00t

  4. #3
    One crazy MOFO/Mail man
    Join Date
    Sep 2002
    Location
    T dot
    Posts
    2,295
    import java.io.*;
    class a1{
    public static void main (String args[]){
    String tmp = null;
    int n=0, total=0,min=9999, max =0, data = 0 ;
    InputStreamReader in= new InputStreamReader(System.in);
    BufferedReader reader = new BufferedReader(in);

    try
    {
    while (true)
    {
    System.out.println("Enter score:");
    tmp= reader.readLine();
    data = Integer.parseInt(tmp);
    if (data==0)
    break;
    n++;
    total +=data;
    if (data<min)
    min = data;
    if (data>max)
    max = data;
    }
    System.out.println ("Max: " + max + "Min: " +min + "Average: " + total/n);

    }
    catch (IOException ex)
    {
    System.out.println("You can't type");
    }


    }
    public static double max (double [][] a )
    {
    double max = 0;
    for (int i = 0; i < a.length; i++)
    {
    for (int j = 0; j < a[i].length; j++)
    {
    if (a[i][j]> max)
    max = a[i][j];
    }
    }
    return max;
    }
    }
    I assuem you can figure out the middle one from the bottom one. My code comes with no garuntees :P
    I just did this to clear my mind... so i can study more hardware
    w00t

  5. #4
    Wannabebig Member
    Join Date
    Feb 2004
    Posts
    9
    I appreciate the help man, it was very helpful. Thanks.

  6. #5
    $3n10r M3mb3r defcon's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,331
    What compiler to you use for java? If you read this GP, it does look syntactically like c++, but crazy struct. lol, looks interesting.
    Last edited by defcon; 04-26-2004 at 09:27 AM.

  7. #6
    Wannabebig Member
    Join Date
    Feb 2004
    Posts
    9
    I use JBuilder.

  8. #7
    y0 aidano's Avatar
    Join Date
    Nov 2002
    Location
    California
    Posts
    992
    It's probably the official Java compiler from Sun. Most people use it.

    People wonder why I call myself Mr. T. One dude asked, 'does the T stand for tough?' I said no. Another dude asked if the T stands for my last name, Tureaud. No it does not. The 'T' in Mr. T stands for tuna. T loves tuna.

  9. #8
    Journalist galileo's Avatar
    Join Date
    Jul 2002
    Posts
    9,290
    IBM Eclipse is a very good compiler. eclipse.org

  10. #9
    y0 aidano's Avatar
    Join Date
    Nov 2002
    Location
    California
    Posts
    992
    Not to nitpick, but Eclipse is not really a compiler. It's more of a platform for development and uses other compilers. If you're using Eclipse, you're probably using it along with Sun's Java compiler.

    People wonder why I call myself Mr. T. One dude asked, 'does the T stand for tough?' I said no. Another dude asked if the T stands for my last name, Tureaud. No it does not. The 'T' in Mr. T stands for tuna. T loves tuna.

  11. #10
    Wannabebig Member
    Join Date
    Feb 2004
    Posts
    9
    i have another question that's probably easy for you guys. Let's say i find a max in an array using:

    double max = a[0];
    for (int i = 1; i < a.length; i++0)
    if ( a[i]>max)
    max = a[i];
    return max;

    What changes would i make to find the min?

  12. #11
    y0 aidano's Avatar
    Join Date
    Nov 2002
    Location
    California
    Posts
    992
    Just one character

    C'mon. I'm not telling you the answer - I know you can get it yourself by just trying to understand what the code is doing.
    Last edited by aidano; 04-28-2004 at 06:35 PM.

    People wonder why I call myself Mr. T. One dude asked, 'does the T stand for tough?' I said no. Another dude asked if the T stands for my last name, Tureaud. No it does not. The 'T' in Mr. T stands for tuna. T loves tuna.

  13. #12
    $3n10r M3mb3r defcon's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,331
    Yes, I am GREATER then you, oh i'm sorry, I must have posted this in the wrong topic, I meant to put is in a LESSER important one :P

  14. #13
    Wannabebig Member
    Join Date
    Feb 2004
    Posts
    9
    I know it needs to be changed to lesser than in the if statement. I was unsure if it needed to also be switched in the for statement. Any help?

  15. #14
    y0 aidano's Avatar
    Join Date
    Nov 2002
    Location
    California
    Posts
    992
    Dry run the code on paper, writing out the values of all the variables for each iteration of the loop. It won't take long for a piece of code that short, and after you're done you'll understand it all.

    People wonder why I call myself Mr. T. One dude asked, 'does the T stand for tough?' I said no. Another dude asked if the T stands for my last name, Tureaud. No it does not. The 'T' in Mr. T stands for tuna. T loves tuna.

  16. #15
    Wannabebig Member
    Join Date
    Feb 2004
    Posts
    9
    Ok, I have concluded to just change it in the if statement.

Bookmarks

Posting Permissions

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