Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.24 KB | None | 0 0
  1. package TortugasNinja;
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class TortugasNinja {
  8. public static void main(String[] args) {
  9.     int numbadguys=0;
  10.     int numinnocent=0;
  11.     double leonardo1=0;
  12.     double michelangelo1=0;
  13.     double donatello1=0;
  14.     double raphael1=0;
  15.     boolean donatrue=false;
  16.     boolean michatrue=false;
  17.     boolean raphtrue=false;
  18.     boolean leotrue=false;
  19.  
  20.                     Scanner scan = new Scanner(System.in);
  21.                     int var;
  22.                     boolean quit = false;
  23.                    
  24.                     while(!quit){
  25.                             System.out.println("Please Make a selection:");
  26.                             System.out.println("[1] Show badguys");
  27.                             System.out.println("[2] Show innocents");
  28.                             System.out.println("[3] Realization");
  29.                             System.out.println("[4] Show innocents");
  30.                             System.out.println("[5] Balance");
  31.                             System.out.println("[6] Show innocents");
  32.                             System.out.println("[7] Show innocents");
  33.                             System.out.println("[8] exit");
  34.                             System.out.println("Selection: ");
  35.                             var = scan.nextInt();
  36.                    
  37.                             switch (var){
  38.                                     case 1:
  39.                                         boolean dummy = true;
  40.                                         Scanner badguys = new Scanner(System.in);
  41.                                         int malos;
  42.                                         do
  43.                                         {
  44.                                          System.out.println("Input the amount of bad guys caught today.");
  45.                                          malos = badguys.nextInt();
  46.  
  47.                                          if(malos > 0)
  48.                                           break;
  49.                                          else
  50.                                           System.out.println("Error: Input a non-negative amount of bad guys.");
  51.                                         } while (dummy == true);
  52.                                         System.out.println("There are " + malos + " bad guys caught.");        
  53.                                         numbadguys=malos;    
  54.                                         break;
  55.                                     case 2:
  56.                                             System.out.println("Innocents saved");
  57.                                             boolean dummy1 = true;
  58.                                             Scanner innocent = new Scanner(System.in);
  59.                                             int innocentes;
  60.                                             do
  61.                                             {
  62.                                              System.out.println("Input the amount of bad guys caught today.");
  63.                                              innocentes = innocent.nextInt();
  64.  
  65.                                              if(innocentes > 0)
  66.                                               break;
  67.                                              else
  68.                                               System.out.println("Error: Input a non-negative amount of innocents.");
  69.                                             } while (dummy1 == true);
  70.                                             System.out.println("There are " + innocentes + " innocents saved.");        
  71.                                             numinnocent=innocentes;
  72.                                             break;
  73.                                     case 3:
  74.                                     Scanner tortuga = new Scanner(System.in);
  75.                                     System.out.println("Turtle name?");
  76.                                     String turtle = tortuga.nextLine();
  77.                                     System.out.println(turtle);
  78.                                     if (turtle.toUpperCase().equals("DONATELLO") && donatrue == false){
  79.                                         System.out.println(turtle);
  80.  
  81.                                         while( tortuga.hasNextDouble()){
  82.                                             System.out.println("Realizacion");
  83.                                             double dona = tortuga.nextDouble();
  84.  
  85.                                             if (dona < 10 && dona > 0){
  86.                                                
  87.                                                 donatello1=dona;
  88.                                                 donatrue = true;
  89.                                                 System.out.println("Done!");
  90.                                                 break;
  91.                                             } else {
  92.                                                 System.out.println("Try again.");
  93.                                               }
  94.                                         }
  95.                                        
  96.                                    
  97.                                     }else {
  98.                                         System.out.println("Already done!");
  99.                                     }
  100.                                         break;
  101.                                     case 5:
  102.                                         if(numbadguys>numinnocent){
  103.                                             System.out.println("Negative");
  104.                                         }
  105.                                         else if(numbadguys - numinnocent == 0){
  106.                                             System.out.println("Neutral");
  107.                                         }
  108.                                         else{
  109.                                             System.out.println("Positive!");
  110.                                         }
  111.  
  112.                                         break;
  113.  
  114.                                     case 8:
  115.                                             quit = true;
  116.                                             break;
  117.                             }
  118.                     }
  119.                    
  120.                     scan.close();
  121.             }
  122.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement