Well I would suggest you to try http://opencv.org/
I guess willowgarage is an older link. And from what you have written ,seems that its an installation problem
Salem commented: nicely put +17
Well I would suggest you to try http://opencv.org/
I guess willowgarage is an older link. And from what you have written ,seems that its an installation problem
Here is a link that might get all your concepts pretty much clear
http://www.dedoimedo.com/computers/dual-boot-windows-7-ubuntu.html
Paste what output you are getting before problem occurs
Or what you could do is write a print statement in every function at the beginning so you can atleast know which function is messed up
int[] sortedArray = bubbleSort(points);
This function must be outside the for loop, that means you call the function only after you are done entering all the numbers.
EDIT : Post whatever errors/exceptions you are getting now
package junit.framework does not exist
Thats where your problem lies. This previous thread might help
http://www.daniweb.com/software-development/java/threads/355349
cout << students.name << " " << students.age << "yrs" << endl;
Put this in a new loop from 0 to 4 again. What you have done will not print since i will be incremented to 5 and there is no element at 5th position in array.You will again have to loop through entire array from the beginning and print element one by one
Post your latest code along with error (if any) or output. We already know your expected output now. Post what you are getting
int i should be outside struct definition. Still post what error you are getting
What I would like to suggest to you now is something you can call as "dry run".
You take a piece of paper and pencil, start from main , and work through the entire flow of your program. Like when a function is called go to that function, see the initial values of all variables, compute on paper how they are being modified and whether the modifications are correct. Move according to the flow how your program is going to take and check out all possibilities. You can try doing this first when you wake up tomorrow and are all up to code again :)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
There you go. That IS your problem.
Follow the suggestion that cOrRuPtG3n3t!x just gave and I think you will be through. Your array is not being created as an array of 3 elements since you are attempting to create the array first and then setting its size parameter to 3.
And next time make sure you post you error/exception right from the beginning so it becomes much easier for us to help you out. :)
Read DJSAN10's post ... So that might be the problem, why not make the Bank constructor accept an int argument to assign a value to numAct for each instance
Exactly, I was about to suggest the same
Okay in your constructor for bank, there is a line
accounts = new Account[numAct];
and then you are doing
ccounts.setNumAct(numAct);
Thus when in your constructor , numAct is nothing but 0
public int numAct = 0;
and
accounts = new Account[numAct];
..????
and where is your main function?
I did not understand your question.It is going in the if statement for the first time according to what output you are getting. I suppose your problem is something else.
done = true;
and
while(! done)
Assuming initially value of done was false, so !done evaluated to true and you entered while loop for the first time. But when you assign true to done, while will evaluate to false , and you will not go inside the loop at all.
I think you should change it to,
while(done)
All in all, I don't find a good use of while inside for in your case
1.Take number of rows as input from user
2.Loop until all rows are done
3.According to the pattern, number of elements in a row = row number itself. Loop for printing elements in 1 row. If the element number you are printing is odd ,print 1, if it is even print 0.
Start coding and post back if you have any further problems in your code.
So what you can do is, till you reach that max possible value, increment(here multiply) accordingly, after that , decrement(here divide) accordingly.
Also note the number of elements in each row. They follow a pattern too. Try guessing that on your own . If you don't get it we will help you. You can then use that value as condition in your loop. Enjoy coding :)
You can think of it like this : in terms of row no. and max possible value i.e. (We consider row 1 as row 0 )
row 0 , max possible 1
row 1 , max possible 2
row 2 , max possible 4
row 3 , max possible 8
row 4 , max possible 16
row 5 , max possible 32
row 6 , max possible 64
row 7 , max possible 128
Now , can you make out the pattern..????
for (k = 1; k < i*2; )
i's maximum value will be 8 . Hence condition k < i * 2, means k can at the max be 16 . It will never go ahead of 16.
.if the above condition is false i dont want my code to go further and calculate the input.How and i able to do this.Presently everytime i enter an invalid number ,it still processes the output but also come up with the statement"invalid number".
If you want to straight away exit your program you will have to use exit() inside if statement. If you are in a loop and simply want to get out of the loop then you will have to use break as mentioned by adil bashir
if(a < 1 || b < 1 || c < 1 || d || 1)
{
System.out.print("Invalid Input");
break;
}
You need to decide whether you want to use '&&' or '||' depending on what condition you wan to check. If you are looking for any one of a,b,c,d to be < 1 then above code using or condition is fine . If your condition is true when all a,b,c,d < 1 , then you will have to use and (&&) instead
Whenever a function is called , it is pushed on to a stack (called as a frame). Whenever a function returns, it's frame is popped out. This is how flow is maintained. Now , suppose you call a function inside main() , and that function calls exit() , which is also a function, exit is responsible for clearing (popping) stack frames for all functions below it in stack (including main()), and thus process is killed.
I do not have much idea about how it is actually implemented though. I have explained it to you in a very abstracted way, there are many more details involved
You have understood the concept , i guess . But the way u have put it is a little ...ummm....
The pointer variable '*p' does get reassigned to the value of the pointer variable '*q' (98). So essentially both pointer variables (*p, *q) hold the value 98.
This is OK..
Now,
Because the address of the variable 'x' and 'y' are held in pointer variables '*p' and '*q' respectively, when the system calls to output 'x' it looks for the location of 'x' (&x), which is stored in '*p' and then outputs the value of where that location is: value of '*p' (98). And the same with 'y'. Correct?
I would put it something like this,
Whenever you say *p = some_value , what is done here is set some_value to the value of location pointed by p
Thus , when you do *p = 35; , it is same as x = 35
when you do *p = *q , you are doing nothing but x = y
int *p = &x;
You can break this statement as
int *p; // Define a pointer to an integer (p is a variable that
// is capable of holding address of an integer variable
p = &x; // & can be said to be 'address of' operator. hence
// assign to p address of variable x
Now whenever you say, *p , it means de-referencing p. That means , *p gives you value of variable at address contained in p i.e. nothing but value of x
fork returns two values ,0 for child process, and pid of child for parent process. Hence , your if is always true and it runs for parent. If you want some code to run for child you will have to check
if(fork() == 0){
// your code
}
Mark it solved if it is working
Compile time errors are syntactic errors, they are notified at compile time i.e. before you run your program . Exceptions are run time errors.
Compiler does not recognize them. You know you have encountered an exception only once you execute a program.
if(a!=52||a!=55) //this condition is not working?
Since you want to count those which are not 4 or which are not 7,
this should work according to me...
if(a[i]!=52 && a[i]!=55)
Use AND condition
for (a = 0;j< size-1; j++)
What is 'a' ? I think it should be j ?
void swap (int *x,int *y);
You have written a function prototype inside another function. That is wrong
void dataSort (float sLengthArray[],float rSlopeArray[],float speedArray[], float size)
I find only three arrays here,not 4
Could you explain your problem and your code more clearly...
What exactly is the output you want to achieve?
Can you give us an idea of what you want to do next or are you asking for suggestions for what to do next?
As zeroliken said, now let us know what exactly you want..
Inheritance is one of the object oriented concepts . Check these out :
http://www.inf.ufsc.br/poo/smalltalk/ibm/tutorial/oop.html
http://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html
First of all ,use code tag whenever you put a code.
As for your solution you need to add an empty implementation of keyTyped() in your class since you have inherited java.awt.event.KeyListener ,you will need to implement all methods specified in it.
You are re declaring lettergrade1. You don't need to say string inside your if else blocks. Also , since you only want a single character i.e. A,B,C,D, F ..why not use a char instead
you have probably named your class as RunGame .It should be TestDrive
Are you running your code in an ide or via command line. Also , check the condition if(conn == null). If it is null it means connection is not being established.
Do you get an exception...?? Try finding out whether conn is null. This will confirm whether connection is being established or not in the first place.
One more thing, in the default case put an exit() statement so that the user cannot enter more choices. Usually , what you are supposed to do is something like this:
Add 1 more case as follows and use default if a user enters a wrong value
case 5 :
printf ("Exitting");
exit(0);
default :
printf ("Invalid choice : Enter a valid choice");
Now your program becomes a little more interactive than before. :)
Initially choice = 0, and in the first iteration itself while condition is false. Now here you can use a do while. Also put the switch case inside the while loop as pointed by Sky Diploma
Just another suggestion how you could do it.. (No need of using do while)
while(1)
{
if(...)
{
}
else if(...)
{
}
else if(...)
{
}
else
break;
}
According to me , what you want is
else if((hari>=2)&&(hari<5))
Beacuse your two statements are contradictory :
while(hari < 1)
and
else
break
Make the change that zeroliken just mentioned. Also change your while to while(hari > 1). You will not require the else part also in that case
Also , the class that contains your main() class should be your filename. Execute that class then.
since it would be in the same class file, he could just use
Java Syntax (Toggle Plain Text)show();
Yes true
as for the other one, don't say: apart from -> that means, do both.
if he moves the main method to the Static_demo class and then tries to run the static_demo1 class, he would get exactly the same error, since: the main method will not be found
Well thanks for correcting me. You are right ,'apart from' is misleading. But anyways you posted what I actually wanted to convey :)
Apart from what stultuske said , I think you are executing static_demo class. Instead run static_demo1 class. Also you need to create object of static_demo in main(). What is x1 ? You should be calling it as static_class.show().
You can first Convert your decimal to binary and then group them into digits of four and use a switch case for your sixteen hexadecimal digits.That is just 1 way of doing it.I suggested it so that you can use your above program for the same.
Also, if possible paste what output you are getting.Is it atleast printing Total Vikt ?
ryggsackArray[arrayCounter] = s;
I think that is where your problem lies.Try using a copy constructor
Method1
(The XOR trick) a ^= b ^= a ^= b;
Although the code above works fine for most of the cases, it tries to modify variable 'a' two times between sequence points, so the behavior is undefined. What this means is it wont work in all the cases. This will also not work for floating-point values. Also, think of a scenario where you have written your code like this
swap(int *a, int *b)
{
*a ^= *b ^= *a ^= *b;
}
Now, if suppose, by mistake, your code passes the pointer to the same variable to this function. Guess what happens? Since Xor'ing an element with itself sets the variable to zero, this routine will end up setting the variable to zero (ideally it should have swapped the variable with itself). This scenario is quite possible in sorting algorithms which sometimes try to swap a variable with itself (maybe due to some small, but not so fatal coding error). One solution to this problem is to check if the numbers to be swapped are already equal to each other. swap(int *a, int *b) {
if(*a!=*b) { *a ^= *b ^= *a ^= *b; } }
Method2 This method is also quite popular a=a+b; b=a-b; a=a-b; But, note that here also, if a and b are big and their addition is bigger than the size of an int, even this might end up giving you wrong results. Method3 One can …