Search:

Type: Posts; User: hkfrenchtoast

Page 1 of 2 1 2

Search: Search took 0.24 seconds.

  1. Replies
    11
    Views
    262

    Re: Another Array Problem

    Oh! So the string length would be 2?

    and the character length would be 13?
  2. Replies
    11
    Views
    262

    Re: Another Array Problem

    But myArray.length is 11 though

    so i=10;

    for int i=0; 10<11; i++

    so it should run again right? There shouldn't be an error.
  3. Replies
    11
    Views
    262

    Re: Another Array Problem

    Well, I just guessed and inputted random for parameters and managed to get the answer correct with:

    for (int i = 0; i <= scores.length-3; i++)

    Not sure why though.
  4. Replies
    11
    Views
    262

    Re: Another Array Problem

    The assignment says: "return true if the array contains 3 adjacent scores that differ from each other by at most 2"

    5-5=0, 5-3=2 2<3 so it's true.
  5. Replies
    11
    Views
    262

    Re: Another Array Problem

    No, scoresClumb{3,4, 6} is false. 6-4=2 and 4-3=1. 2+1=3. 3>2, so it has to be false.



    Mhm... After looking at the loop over and over again, I still see nothing wrong with the loop. Shouldn't...
  6. Replies
    11
    Views
    262

    Another Array Problem

    Assignment:
    Given an array of scores sorted in increasing order, return true if the array contains 3 adjacent scores that differ from each other by at most 2, such as with {3, 4, 5} or {3, 5, 5}.
    ...
  7. Replies
    14
    Views
    322

    Re: Array Problem

    Okay, I understand the reasoning behind it, but I do not understand the &true thing. What is that? I haven't seen that before.

    I only seen temp=true or temp=false

    but not temp=temp&true.
  8. Replies
    14
    Views
    322

    Re: Array Problem

    Okay, I did what you said:


    class Test
    {
    private String temp = "false";
    void scoresIncreasing(int[] scores)
    {
    for (int i = 0; i< scores.length-1; i++)
    {
  9. Replies
    2
    Views
    237

    Re: gradebook

    Hello. I don't understand what all this is for:

    avg= sum/ numberofgrades;
    System.out.println("Total number of grades is "+ numberofgrades);
    System.out.println("Total number of A's is "+A);...
  10. Replies
    14
    Views
    322

    Re: Array Problem

    Sorry to bump this, but I really want to know how to make the code work. :/
  11. [SOLVED] Re: Not sure how to copy and paste(Highlight) my code onto the forums...

    All you have to do is just type the code tag and than your code and than end it with the code tag.
  12. Replies
    14
    Views
    322

    Re: Array Problem

    Removing "|| scores[i] == scores [i+1]" ?

    That does not work. The output is still: true false. Besides, I need it to complete the assignment (return true if each score is equal).

    I know what...
  13. Replies
    14
    Views
    322

    Re: Array Problem

    I ran the code again with {1,3,2} and got

    Output:


    I am not sure what the problem is. I forgot to mention that the assignment is from CodingBat AP-1 question.
  14. Replies
    14
    Views
    322

    Re: Array Problem

    --- Update ---

    [/COLOR]NVM, I am a retard. I tested {3,2} and got False.


    class Test
    {
    void scoresIncreasing(int[] scores)
    {
    for (int i = 0; i< scores.length-1; i++)
  15. Replies
    14
    Views
    322

    Array Problem

    The exercise:
    Given an array of scores, return true if each score is equal or greater than the one before. The array will be length 2 or more.

    scoresIncreasing({1, 3, 4}) → true...
  16. Replies
    25
    Views
    345

    Re: Few errors on my code.

    Javac does not recognize the Error. Perhaps it's just an Eclipse thing? I ran javac on console. No error from that. The code just runs.

    --- Update ---

    Okay, I managed to fix the NULL problem...
  17. Replies
    25
    Views
    345

    Re: Few errors on my code.

    I did in an earlier post:



    That's all it says on the Compiler (Eclipse)

    The code runs, but it says there's an
  18. Replies
    25
    Views
    345

    Re: Few errors on my code.

    The code does run on javac, however...When I go to the Status (Pmenu method) in my code, all the stuff are NULL. like
    Name= Null
    Gender = Null
    Hair Color= Null .....

    Compiler error is on Line 2...
  19. Replies
    25
    Views
    345

    Re: Few errors on my code.

    Yes, of course!


    import java.util.Scanner;

    class Player {
    private String name;
    private String gender;
    private String hcolor;
    private String ecolor;
  20. Replies
    25
    Views
    345

    Re: Few errors on my code.

    I changed the pmenu to
    Roleplaygame2.pmenu(place);

    But that just gave me another error:



    Looking at the code, Player type wasn't already defined...
  21. Replies
    25
    Views
    345

    Re: Few errors on my code.

    Well I fixed the trivial mistakes from post number 4. I ended up with a single error:


    import java.util.Scanner;

    class Player {
    private String name;
    private String gender;
    private...
  22. Replies
    25
    Views
    345

    Re: Few errors on my code.

    Wow, that makes so much sense HAHA (EDIT: NVM. Look at bottom!). There was another solution that I found to this code too: (Turning everything into statics)

    import java.util.Scanner;

    class...
  23. Replies
    25
    Views
    345

    Re: Few errors on my code.

    Yeah, I put that after observing my code. But it did not fix anything.
  24. Replies
    25
    Views
    345

    Re: Few errors on my code.

    No spelling mistakes... Not sure what is wrong? Is it because of the placement of the code?
  25. Replies
    25
    Views
    345

    Re: Few errors on my code.

    Okay, I fixed the problem. However, I added a new method for the Town Menu. I am getting errors


    import java.util.Scanner;



    class Player {
    private String name;
    private String gender;
Results 1 to 25 of 38
Page 1 of 2 1 2