Home / Expert Answers / Computer Science / nbsp-using-java-please-invoking-math-random-returns-a-pseudo-random-number-of-type-double-fr-pa734

(Solved):   using java please Invoking Math.random() returns a (pseudo)random number of type double fr ...



Invoking Math.random() returns a (pseudo)random number of type double from the half-open interval \( [0,1) \). Use this gener

 

using java please

Invoking Math.random() returns a (pseudo)random number of type double from the half-open interval \( [0,1) \). Use this generator to draw cards from a standard deck. First, draw an integer from the interval \( [1,4] \) (corresponding to suit: clubs, diamonds, hearts, spades) and then another number from the interval \( [2,14] \) (deuce, trey, four, five, ..., ten, Jack, Queen, King, Ace). Using the switch expression, define strings describing cards and display five such random cards on the console. For example, the following program public class Cards \{ public static void main(String [ ] args) \{ for (int \( i=0 ; i<5 ;++i)\{ \) /* * Define two integers using only Math.random(): * col is a random integer from range [1, 4] * rnk is a random integer from range [2, 14] */ String color \( =\operatorname{switch}(\operatorname{col})\{ \) \}; String rank \( =\operatorname{switch}( \) rnk \( )\{ \) \}; System.out.println(rank \( + \) " of " + color); \} \} \} could print Five of Spades Queen of Clubs Seven of Diamonds Deuce of Hearts Eight of Hearts


We have an Answer from Expert

View Expert Answer

Expert Answer


Input for the java program:- public class Cards { public static void main(String args[]) { int col,rnk; for(int i=0;i<5;++i) { //Math.random() to

We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe