Oh! So the string length would be 2?
and the character length would be 13?
Type: Posts; User: hkfrenchtoast
Oh! So the string length would be 2?
and the character length would be 13?
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.
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.
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.
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...
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}.
...
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.
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++)
{
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);...
Sorry to bump this, but I really want to know how to make the code work. :/
All you have to do is just type the code tag and than your code and than end it with the code tag.
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...
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.
--- 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++)
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...
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...
I did in an earlier post:
That's all it says on the Compiler (Eclipse)
The code runs, but it says there's an
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...
Yes, of course!
import java.util.Scanner;
class Player {
private String name;
private String gender;
private String hcolor;
private String ecolor;
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...
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...
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...
Yeah, I put that after observing my code. But it did not fix anything.
No spelling mistakes... Not sure what is wrong? Is it because of the placement of the 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;