Menu

(Solved) : Gambler Plays Double Dice Throw Gamble Money Casino Gambler Gamble 1 100 Two Dices Tossed Q33141040 . . .

A gambler plays a double dice throw to gamble his money in casino. The gambler can gamble between $1 to $100. Two dices are tossed, and the gambler wins or loses money based on following scenarios I. If the sum of numbers for the two dices is 5 and above but less than 10, the gambler loses 40% of the money that he gambles. If the sum of numbers for the two dices are less than 5, the gambler loses 70% of the money If the sum of numbers for the two dices are 10 or above, the gambles investment is doubled 2. 3. Write a java program that: 1. Simulates 10000 dice throw events, and prints it to a file named dice.txt. A dice throw event looks like this 1 2 30 where 1 is the number on first dice, 2 on the second dice, and 30 is the amount gambled on this event. Reads dice.txt and calculates wins or losses for each throw based on the above rules, and prints the throw outcomes along with the win or loss to a file named details.txt. An outcome looks likes this Dicel Dice2 Total Amt. Gam Win Loss 2. 30 40 12 (40%) 12 80 3. After calculating wins, and losses for every individual throw, it calculates the following stats and prints them to a file named stats.txt a. Total winning amount b. Total loss amount c. Average winning amount d. Average loss amount e. Largest winning amount f. Largest loss amoun Construct a method named simulateice that simulates the dices to compute the sum of two dices and prints them to dice.txit Construct a method named writeDetails that reads files.txt and writes the details to details.txt Construct a method named writeStats that reads files.txt and writes the details to stats.txt
Cut Copy Paste Undo Redo Find CompileReset Run Test Javadoc Code Co Lx Close File file = new File (filename2); scanner input = new Scanner (file); Printwriter wD new printwriter (details. txt); wD.println(Dicel Dice2 Total Amt Gam Win Loss) 58 59 61 62 63 64 65 do line input, next Line () ; if (numL>O 67 d1 line, substring (0, 5) d2 line.substring (6,11); 68 amtG 1ine. substring (1,line. length 0) a 70 71 72 73 74 75 76 de1 Int eger- parseInt (d1.trim)) dc2 # Integer, parseInt (d2 . t rimo); total dc1fdc2 ; amt Gam Integer parseInt (amtG.trimO) if (total>#5 66 tot al <10) Losst+ 79 if (total<5) losstta 01 82 83 it (total> 10) 85 86 อา wint+ system out printin(dl+h +d2 +totalt amtGtwintloss) wD. printin (dei+ +total+ + amt Gam+ +win+ -+loss) ; 89 90 91 numLt+i head+ti Compiler Output

media%2F0cd%2F0cdde3f7-e64a-4832-9fbb-7d

A gambler plays a double dice throw to gamble his money in casino. The gambler can gamble between $1 to $100. Two dices are tossed, and the gambler wins or loses money based on following scenarios I. If the sum of numbers for the two dices is 5 and above but less than 10, the gambler loses 40% of the money that he gambles. If the sum of numbers for the two dices are less than 5, the gambler loses 70% of the money If the sum of numbers for the two dices are 10 or above, the gamble’s investment is doubled 2. 3. Write a java program that: 1. Simulates 10000 dice throw events, and prints it to a file named dice.txt. A dice throw event looks like this 1 2 30 where 1 is the number on first dice, 2 on the second dice, and 30 is the amount gambled on this event. Reads dice.txt and calculates wins or losses for each throw based on the above rules, and prints the throw outcomes along with the win or loss to a file named details.txt. An outcome looks likes this Dicel Dice2 Total Amt. Gam Win Loss 2. 30 40 12 (40%) 12 80 3. After calculating wins, and losses for every individual throw, it calculates the following stats and prints them to a file named stats.txt a. Total winning amount b. Total loss amount c. Average winning amount d. Average loss amount e. Largest winning amount f. Largest loss amoun Construct a method named simulateice that simulates the dices to compute the sum of two dices and prints them to dice.txit Construct a method named writeDetails that reads files.txt and writes the details to details.txt Construct a method named writeStats that reads files.txt and writes the details to stats.txt Show transcribed image text

Expert Answer


Answer to Gambler Plays Double Dice Throw Gamble Money Casino Gambler Gamble 1 100 Two Dices Tossed Q33141040 . . .

OR