1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Java help!

Discussion in 'Help' started by Slashraider, Mar 25, 2014.

  1. Slashraider

    Slashraider Active Member

    http://imgur.com/CCwIpAm

    On this worksheet I need some help with this problem.



    http://imgur.com/8Nvd8WA

    I keep getting errors for this one. I am not by my computer so u cannot see my code or my errors. If someone can post the finished code for this, I can check it later and fix it.


    Thanks!
     
  2. Dub

    Dub Guest

    I need to learn some type of coding language. :/
     
  3. RJ

    RJ no pay Legend Clockwork Customer

    For the first image:
    Code:
    import java.until.*;
    public class countDiceRolls{
     public static void main(String[] args){
      Random rand = new Random();
      int die1,die2,roll;
      int[] count=new int[13];
    
      for (int j=1; j<=2000; j++){
       die1=(int)Math.rand*6+1;
       die2=(int)Math.rand*6+1;
       roll=die1+die2;
       count[roll]++;
      }
      
      System.out.println("Roll Summary");
      System.out.println("Roll\tFrequency");
      
      for (int j=0; j<count.length(); j++){
       System.out.println(count[j]+"\t"+...);
      }
     }
    }
    I believe that should do it. Sorry about the poor indentation.
     
  4. Kurochi

    Kurochi Active Member

    I WOULDN'T TAKE MY OWN WORD ON THESE, I DON'T REALLY DO JAVA THAT MUCH

    This should be number 40 in second picture

    Code:
    int[] intArray = new int[20]
    Random random = new Random();
    for (int i = 0; i < intArray.length; i++){
    	intArray[i] = random.nextInt(51) + 50;
    }
    
    System.out.println("Original Array");
    System.out.println(Arrays.toString(intArray));
    Arrays.sort(intArray);
    System.out.println("Sorted Array");
    System.out.println(Arrays.toString(intArray));
    As for 38, I'm not entirely sure but I think that printing b results in "WXYZ" and printing c results in "ZYXW"

    I would do 37 but I can't understand if it's referring to an array, an arraylist, or a list.
    Either way it's pretty simple.

    Notes: "length" becomes "size()" if collection is an arraylist/list.
    Code:
    // FOR
    int sum = 0;
    for (int i = 0; i < COLLECTION.length; i++){
    	sum += COLLECTION[i];
    }
    // FOREACH
    for (int i : COLLECTION){
    	sum += i;
    }
    Number 36 would be Arrays.sort(String[])
     
  5. Tommy

    Tommy Guest

    Is Java something that I should be learning? :x
     
  6. Slashraider

    Slashraider Active Member

    Thank you and thanks R.J.! I figured out the other problem on my own but these help a lot!




    I honestly think you should. It is not that hard to learn and it gives you pretty basic skills of coding and a lot of the skills from Java are transferred over to Lua.
     
  7. RJ

    RJ no pay Legend Clockwork Customer

    No problem Slashraider.

    It's simple and widely used. I don't recommend it for professional/long term development but it's a good place to start.
     
  8. Tommy

    Tommy Guest

    At the moment I can only do fundamental lua and basic VB. Is Java easy to learn?
     
  9. JonneBravo

    JonneBravo Guest

    entirely de-railing this thread but im keen to know

    Where should I start with Java? It's a language that included with my college course and I'd like to have some pre-knowledge on the language.
     
  10. Slashraider

    Slashraider Active Member


    I take a class (Have an A xD) so I can send you our lesson plan with power points and practice exercises to help you learn quickly if you want.

    Or you know you can just use google or watch some youtube videos :)
     
  11. JonneBravo

    JonneBravo Guest

    My college course starts in August so I've got a while to learn. I'd appreciate if you could send a beginner lesson-plan or something to begin with.
     
  12. RJ

    RJ no pay Legend Clockwork Customer

    I started using Java in my grade 12 programming class and it was my first time seeing it. I'm about a unit ahead of everyone else so yeah, I guess you could say it's easy.

    It's quite similar to Lua to be honest. You should start with figuring out how to important packages as well as getting used to Java's structure. I'm using NetBeans to program in Java so you could probably take a look at that program to maybe make a few simple programs. As for what to learn, I'd suggest learning about strings, integers, loops (for, while), converting integers to strings (and vice versa), arrays as well as different kinds of integers (int, double, etc.).

    srry for derail
     
  13. Slashraider

    Slashraider Active Member



    I've included 4 attachments here.

    1. Using jGrasp for the first time. jGrasp is the program I use to code Java, but you can use others such as Notepad++ and other you want to use. This attachment shows you how to use jGrasp

    2. Hello World Exercise: Pretty basic, lets you get the feel of Java.

    3. JGrasp Exercises: More exercises to get basic practice with Java.

    4. ch01_1.ppt: A basic powerpoint on the first unit of Java which is: Unit 1 Intro, Print, and Methods







    *IF YOU WANT MORE OR YOU HAVE QUESTIONS PLEASE COME TALK TO ME* :)




    EDIT: Looks like I cannot send the attachments here because they are too large... PM me for these downloads!


    Also if this gets popular or even if only JonneBravo wants this, I can make a new thread because the answer I was looking for this thread was answered.
     

Previous Readers (Total: 0)