Juan Villena

Greenhorn
+ Follow
since Aug 27, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Juan Villena



***AFTER TESTING -- THIS IS THE ERROR ***
Failure: junit.framework.ComparisonFailure: null expected:<[unrecognized token:]$> but was:<[]$>

Hello Everyone, i need some help about throwing an exception in my Junit Test
I am trying throw an exception and pass the test, when the input String found the symbol $
Any Suggestion??

Thanks
12 years ago
Thats what i am doing now, ...
I will post my new code soon... i just want to get more ideas from you

Juan Villena
12 years ago
Hello Everyone, I need some help about this particular program
concisting in analyze the type of shape and output the shape : "("Tree", 8,"*")

I was thinking to create a loop and checking if the first character is blank or
checking the new line to to figure it out the height of the shape and compare it...
Any help, very confusing...
thanks

JUan Villena

12 years ago
thanks winston and everyone who help me, the game coding is resolved

JUan villena
12 years ago
Joanne Neal, thanks for respond,
sorry, the end of the do is:

}while(answer.equals("y") || answer.equals("y"));
}
}

And i think it is working now.
12 years ago

Hello everyone, sorry i could not answer back right away, and thank you for your answers
I just changed the conditionals, using switch and char variables in order to campare , win = w, lose = l, continue = c.

* BUT It returns WRONG answers , when it is NOT a win or a lose MEANS, when it is continue.
* i would like you take a look at the second time when generate the numbers, i use different variable "ddado1" and "ddado2"
because if i continue with the originals "dado1" and "dado2" i got a error, saying that dado1 and dado2 are already define in main(java.lang.String[])

ANY HELP PLEASE.


import java.util.Scanner;
import java.lang.String;
import java.util.Random;
public class Craps
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
String answer;
char stat = ' ';
char gamestat = ' ';
int roll2 = 0;
do
{
Die dado1 = new Die();//store roll1 in a new var1
Die dado2 = new Die();//store roll2 in a new var2

// my point V iqual the sum of the two rolls
int thePoint = (dado1.getRoll() + dado2.getRoll());
System.out.println();
System.out.print("You rolled "+thePoint+" . ");

switch (thePoint)
{
case 7:
case 11:
System.out.println("You Win !");// winner
stat = 'w';
gamestat = stat;
break;

case 2:
case 3:
case 12:
System.out.println("You Lose !");// loser
stat = 'l';
gamestat = stat;
break;

default:
stat = 'c';
gamestat = stat;
break;
}

while ( gamestat == 'c' )
{
Die ddado1 = new Die();//store roll1 in a new var1
Die ddado2 = new Die();//store roll2 in a new var2

roll2 = (ddado1.getRoll() + ddado2.getRoll());

if (roll2 == thePoint){
gamestat = 'w';
System.out.println("You Winnnnn !");
}else if (roll2 == 7){
gamestat = 'l';
System.out.println("You Looooose !");
}
}
*******************************************************
// random numbers class

mport java.util.Random;

public class Die
{
private int tiro;
private final static Random random = new Random();
public Die()
{
tiro =random.nextInt(6) + 1;
}
public int getRoll()
{
return tiro;
}
}



12 years ago
thanks man, it runs now, but i think it doesn not check the condition properly
because i run it and , it says: " you roled 8 you loose"


Harsha Smith wrote:constructor not closed(missing curly brace '}')
Math.random() takes no arguments

Line 29 variable roll2 not declared yet( Craps class)
you may use answer.equalsIgnoreCase("y) (line 48)

12 years ago
Hello everyone, i really need some help in this code "craps game"
thi is the error message i got when i compile, i think im doing somenthing wrong in my class Die
it remarks that public int getRoll() , illegal start of expression


any help
Thank in advance...

2 errors found:
File: C:\Users\sinner7uk\JavaProjects\Die.java [line: 6]
Error: C:\Users\sinner7uk\JavaProjects\Die.java:6: illegal start of expression
File: C:\Users\sinner7uk\JavaProjects\Die.java [line: 6]
Error: C:\Users\sinner7uk\JavaProjects\Die.java:6: ';' expected




*******************************

12 years ago
Hi, in this program, supposed to add odd numbers
it works when num1 <= numb2 : "10, 1"
but when you enter num1 >=numb2 : "10,1" does not work and theres no errors
what condition i have to add (when numb1>=numb2) and where i have to locate it.
Thanks



12 years ago
Thanks a lot
i just did it and it works

12 years ago
Thanks a lot guys, i don't have that error message anymore, and i understand now
but when i enter " Its April" , it just take the lowercase vowel

do i have to write a statement using equalsIgnoreCase() ??
12 years ago
im having problems to figure it out where is probl
everytime i run this, string index out of range comes out as an error.

any suggestion please.

Thanks a lot.

12 years ago
Thanks a lot, I understand now...about Math.class... But my doubt is about the exponent ' 1/2 '. Using the same equation, if I want to elevated it to exponent 1/2, what Math.class should I use n which one is the correct one.
Math.sqrt or Math.pow ??

Thanks
12 years ago
Jesper the jonq, actually , i want to square root the whole equation, an\d is 331

Rob Spoor and Campbell Ritchie: so can i use math.pow in this particular ecuation or just math.sqrt
and can you tell if this is right or wrong : 331*(math.sqrt((t*273)/273)
or can you guys write this ecuation using math class please.

thanks a lot
12 years ago

331.5* (math.sqrt((t*273)/273))
12 years ago