Omar Nasir

+ Follow
since Jul 11, 2005
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Omar Nasir

Hey guys,

I need some help.

Lets say im trying to code a simple game, where I have 4 random numbers, and the player has to:

1) Add, subtract, multiply or divide all 4 numbers with each other to get the number 21.

2) Number can only be used once.

How would i go about with that algorithm?

Thanks, have a nice day
11 years ago
Dear Ramya,

found in the site :

i hope this helps.


12 years ago

Rob Prime wrote:I doubt you can do it with just one single loop.
Consider an array {4, 7, 3}. After not-swapping 4 and 7, the index moves one forward and you swap 7 and 3. The array is then {4, 3, 7}. Doesn't look sorted, does it?

hi guys, im new here and new to java. based on what rob said, i think you should add 1 more loop to check the reverse way.

eg : you got {4,7,3}

currently it will sort to {4,3,7}.

then you check from reverse,

i think you will get


because 7 and 3 will not swap, but 3 and 4 will.

then add 1 more loop to check both sides of array[n], to make sure that its in the right spot.

im still new, but this is my input.
12 years ago
thx lots man. sry bout the name, i changed it. i was in a hury when i signed up, did not read the naming policy. sry again. thx. ^_^
16 years ago
hello there, i am trying to make an applet out of fun. i came across a problem and need u guys to help me out.

my prob is,: take for example im making a calculator. i need to user to input 2 numbers, and a method for calculation ( add, subtract). the user then types "subtract" as method of calculation.

i wrote this:

if(mtdcal == "subtract")
sum = num1 - num2;

mtdcal is what ever that is typed into the textfield by the user.

mtdcal = txt3.getText();

but it wont work after i compile and execute it. pls tell me what to change.
16 years ago