fork download
  1. import java.util.*;
  2.  
  3.  
  4. import java.io.*;
  5.  
  6.  
  7.  
  8.  
  9.  
  10. class MonkSim
  11.  
  12.  
  13.  
  14.  
  15.  
  16. {
  17.  
  18.  
  19.  
  20.  
  21.  
  22. public static void main (String[]args)
  23.  
  24.  
  25. {
  26.  
  27.  
  28.  
  29.  
  30.  
  31. Scanner scan = new Scanner (System.in);
  32.  
  33.  
  34. Random rand = new Random ();
  35.  
  36.  
  37.  
  38.  
  39. int monksPossible;
  40.  
  41.  
  42. int gold;
  43.  
  44.  
  45. int numberOfMonksToCreate;
  46.  
  47.  
  48. int enemyMonks;
  49.  
  50.  
  51. int numberOfMonks;
  52.  
  53.  
  54.  
  55. int casualities;
  56.  
  57.  
  58.  
  59. String answer;
  60.  
  61.  
  62.  
  63. enemyMonks = rand.nextInt(1001);
  64.  
  65.  
  66.  
  67. gold = rand.nextInt(10001)+500;
  68.  
  69.  
  70.  
  71. casualities = rand.nextInt(251);
  72.  
  73.  
  74.  
  75. System.out.println ("You have " + gold + " gold.");
  76.  
  77.  
  78.  
  79.  
  80.  
  81. System.out.println ("How many monks do you wish to create?");
  82.  
  83.  
  84. numberOfMonksToCreate = scan.nextInt();
  85.  
  86.  
  87.  
  88.  
  89.  
  90. monksPossible = gold / 10;
  91.  
  92.  
  93.  
  94.  
  95.  
  96. if (numberOfMonksToCreate <= monksPossible)
  97.  
  98.  
  99. {
  100.  
  101.  
  102. numberOfMonks = numberOfMonksToCreate;
  103.  
  104.  
  105.  
  106.  
  107. System.out.println ("You have recruited " + numberOfMonks + " monk(s).");
  108.  
  109.  
  110.  
  111.  
  112.  
  113. System.out.println ("A legion of enemy monks approaches from the East. Do you wish to attack?");
  114.  
  115.  
  116.  
  117. answer = scan.nextLine();
  118.  
  119.  
  120.  
  121. if (answer.equals ("yes")
  122.  
  123. {
  124.  
  125.  
  126.  
  127. System.out.print ("Your monk(s) rush(es) forward!");
  128.  
  129.  
  130.  
  131. if (enemyMonks >= numberOfMonks)
  132.  
  133. {
  134.  
  135. System.out.println ("Your " + numberOfMonks + " monk(s) fought bravely against " + enemyMonks + " enemy monks, but your monk(s) lost the battle.");
  136.  
  137. }
  138.  
  139. else
  140.  
  141. {
  142.  
  143. System.out.println ("Your " + numberOfMonks + " fought off " + enemyMonks + " enemy monks and won!");
  144.  
  145.  
  146. }
  147. if (casualities < numberOfMonks)
  148.  
  149. {
  150.  
  151. System.out.println ("You had " + casualities + " casualities.");
  152.  
  153. }
  154.  
  155. }
  156.  
  157. }
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. else
  166.  
  167. {
  168.  
  169.  
  170. System.out.println ("You have insufficient funds.");
  171.  
  172.  
  173. }
  174.  
  175.  
  176.  
  177.  
  178.  
  179. System.out.println ("Simulation terminated.");
  180.  
  181.  
  182.  
  183.  
  184.  
  185. }
  186.  
  187.  
  188.  
  189. }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:121: ')' expected
     if (answer.equals ("yes")
                              ^
1 error
stdout
Standard output is empty