Advertisement
Guest User

Task DOer by Salamencizer

a guest
Jun 21st, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 30.08 KB | None | 0 0
  1. import java.io.*;
  2. class Task_Doer
  3. {
  4.     private static int random()
  5.     {
  6.         double t                                                                                                      ;
  7.         int j;
  8.         t=Math.random()                                                                                            ;
  9.         t=t*100                                                                                                     ;
  10.         j=(int) t                                                                                                  ;
  11.         return (j%10)                                                                                            ;
  12.     }
  13.  
  14.     public static void main()throws IOException
  15.     {
  16.         InputStreamReader read = new InputStreamReader(System.in);
  17.         BufferedReader in = new BufferedReader(read);
  18.         boolean baba=false;
  19.         int nootimes=1;
  20.         do
  21.         {
  22.             System.out.print("\u000c");
  23.             System.out.println("-----------------------------------------------------");
  24.             System.out.println("|  Welcome to the awesome Task DOer ©® !!!          |");
  25.             System.out.println("-----------------------------------------------------");
  26.             System.out.println("Enter the task you wanna do among:");
  27.             System.out.println("");
  28.             System.out.println(" ---->Calculations");
  29.             System.out.println("");
  30.             System.out.println(" ---->Future Prediction");
  31.             System.out.println("");
  32.             System.out.println(" ---->Grade Calculator");
  33.             System.out.println("");
  34.             System.out.println(" ---->Letter Triangle Maker");
  35.             System.out.println("");
  36.             System.out.println(" ---->Buzz Number checker");
  37.             System.out.println("");
  38.             System.out.println(" ---->String Reverser");
  39.             System.out.println("");
  40.             System.out.println(" ---->Coin Tosser");
  41.             System.out.println("");
  42.             System.out.println(" ---->Circumference Finder");
  43.             System.out.println("");
  44.             System.out.println(" ---->Random Number Generator");
  45.             System.out.println("");
  46.             System.out.println(" ---->Salamencizoric Code Converter");
  47.             System.out.println("");
  48.             System.out.println(" ---->Random_Programinator");
  49.             System.out.println("");
  50.             System.out.println(" ---->DreSalam Code Converter");
  51.             System.out.println("");
  52.             String task=in.readLine();
  53.             char t=(task.toUpperCase()).charAt(0);
  54.             if(t=='C')
  55.             {
  56.                 if(task.charAt(1)=='a'||task.charAt(1)=='A')
  57.                     calculator();
  58.                 if(task.charAt(1)=='o'||task.charAt(1)=='O')
  59.                     coin();
  60.                 if(task.charAt(1)=='i'||task.charAt(1)=='I')
  61.                     circ();
  62.             }
  63.             else if(t=='F')
  64.                 future();
  65.             else if(t=='G')
  66.                 grade();
  67.             else if(t=='L')
  68.                 lettertriangle();
  69.             else if(t=='B')
  70.                 buzz();
  71.             else if(t=='R')
  72.                 randprog();
  73.             else if(t=='S')
  74.             {
  75.                 if(task.charAt(1)=='t'||task.charAt(1)=='T')
  76.                     reverse();
  77.                 if(task.charAt(1)=='a'||task.charAt(1)=='A')
  78.                 {
  79.                     boolean baoba=false;
  80.                     long noo=1;
  81.                     do
  82.                     {
  83.                         String sent="",cord="";
  84.                         System.out.print("\u000c");
  85.                         System.out.println("-----------------------------------------------------");
  86.                         System.out.println("Welcome to the code generator. What do you wanna do? |");
  87.                         System.out.println("-----------------------------------------------------");
  88.                         System.out.println(" ---->Transform a sentence to a code\tEnter transform");
  89.                         System.out.println("");
  90.                         System.out.println(" ---->Decode a code sentence        \tEnter Decode");
  91.                         System.out.println("");
  92.                         char wtd= ((in.readLine()).toUpperCase()).charAt(0);
  93.                         if(wtd=='T')
  94.                         {
  95.                             System.out.println("Enter the sentence to be transformed. (EVERTHING MUST BE CAPS)");
  96.                             sent=in.readLine();
  97.                             cord=encrypt(sent);
  98.                             System.out.println(" *****Transformation completed!! The code is: *****");
  99.                             System.out.println(cord);
  100.                         }
  101.                         else if(wtd=='D')
  102.                         {
  103.                             System.out.println("Enter the sentence to be decoded. (EVERTHING MUST BE CAPS)");
  104.                             sent=in.readLine();
  105.                             cord=encrypt(sent);
  106.                             System.out.println(" *****Decoding completed!! The code is: *****");
  107.                             System.out.println(cord);
  108.                         }
  109.                         else
  110.                         {
  111.                             System.out.println("Sorry, enter something valid!!");
  112.                         }
  113.                         System.out.println("Repeat the program??\t\t\t    Y/N/y/n/yep/yeah/no/yes/nope/neva");
  114.                         char yn=in.readLine().charAt(0);
  115.                         if(yn=='Y'||yn=='y')
  116.                         {
  117.                             noo++;
  118.                             baoba=true;
  119.                         }
  120.                         else
  121.                             baoba=false;
  122.                         System.out.print("\u000c");
  123.                     }
  124.                     while(baoba);
  125.                     System.out.println("You have used this program "+noo+" times.");
  126.                     System.out.println("Thanks for using this program.");
  127.                 }
  128.             }
  129.             else if(t=='R')
  130.                 random5();
  131.             else if(t=='D')
  132.             {
  133.                 boolean baoba=false;
  134.                 long noo=1;
  135.                 do
  136.                 {
  137.                     String sent="",cord="";
  138.                     System.out.print("\u000c");
  139.                     System.out.println("-----------------------------------------------------");
  140.                     System.out.println("Welcome to the code generator. What do you wanna do? |");
  141.                     System.out.println("-----------------------------------------------------");
  142.                     System.out.println(" ---->Transform a sentence to a code\tEnter transform");
  143.                     System.out.println("");
  144.                     System.out.println(" ---->Decode a code sentence        \tEnter Decode");
  145.                     System.out.println("");
  146.                     char wtd= ((in.readLine()).toUpperCase()).charAt(0);
  147.                     if(wtd=='T')
  148.                     {
  149.                         System.out.println("Enter the sentence to be transformed. (EVERTHING MUST BE CAPS)");
  150.                         sent=in.readLine();
  151.                         cord=dre(sent);
  152.                         System.out.println(" *****Transformation completed!! The code is: *****");
  153.                         System.out.println(cord);
  154.                     }
  155.                     else if(wtd=='D')
  156.                     {
  157.                         System.out.println("Enter the sentence to be decoded. (EVERTHING MUST BE CAPS)");
  158.                         sent=in.readLine();
  159.                         cord=dre(sent);
  160.                         System.out.println(" *****Decoding completed!! The code is: *****");
  161.                         System.out.println(cord);
  162.                     }
  163.                     else
  164.                     {
  165.                         System.out.println("Sorry, enter something valid!!");
  166.                     }
  167.                     System.out.println("Repeat the program??\t\t\t    Y/N/y/n/yep/yeah/no/yes/nope/neva");
  168.                     char yn=in.readLine().charAt(0);
  169.                     if(yn=='Y'||yn=='y')
  170.                     {
  171.                         noo++;
  172.                         baoba=true;
  173.                     }
  174.                     else
  175.                         baoba=false;
  176.                     System.out.print("\u000c");
  177.                 }
  178.                 while(baoba);
  179.                 System.out.println("You have used this program "+noo+" times.");
  180.                 System.out.println("Thanks for using this program.");
  181.             }
  182.             else
  183.                 System.out.println("Sorry, wrong choice!");
  184.             System.out.println("Back to the Task DOer ©® !!");
  185.             System.out.println("Repeat the program??\t\t\t    Y/N/y/n/yep/yeah/no/yes/nope/neva");
  186.             char yn=in.readLine().charAt(0);
  187.             if(yn=='Y'||yn=='y')
  188.             {
  189.                 nootimes++;
  190.                 baba=true;
  191.             }
  192.             else
  193.                 baba=false;
  194.             System.out.print("\u000c");
  195.         }
  196.         while(baba);
  197.         System.out.println("You have used this program "+nootimes+" times.");
  198.         System.out.println("Task DOer developed and made by Salamencizer");
  199.         System.out.println("Thanks for using this program.");
  200.     }
  201.  
  202.     private static void calculator()throws IOException
  203.     {
  204.         InputStreamReader read = new InputStreamReader(System.in);
  205.         BufferedReader in = new BufferedReader(read);
  206.         char o;
  207.         System.out.println("\u000c");
  208.         char yn=' ';
  209.         int b=1;
  210.         boolean value=false;
  211.         do
  212.         {
  213.             System.out.print("\u000c");
  214.             double c,d,a;
  215.             System.out.println("Calculator");
  216.             System.out.println("Enter:");
  217.             System.out.println("A for Addition");
  218.             System.out.println("B for Subtraction");
  219.             System.out.println("C for Multiplication");
  220.             System.out.println("D for Quotient");
  221.             System.out.println("E for Remainder");
  222.             System.out.println("F for Square Root");
  223.             System.out.println("G for Cube Root");
  224.             System.out.println("H for Power");
  225.             o=(in.readLine().toUpperCase()).charAt(0);
  226.             if(o=='A')
  227.             {
  228.                 System.out.println("Enter the two no.s");
  229.                 c=Double.parseDouble(in.readLine());
  230.                 System.out.println("+");
  231.                 d=Double.parseDouble(in.readLine());
  232.                 a=c+d;
  233.                 System.out.println(c+" + "+d+" = "+a);
  234.             }
  235.             else if(o=='B')
  236.             {
  237.                 System.out.println("Enter the two no.s");
  238.                 c=Double.parseDouble(in.readLine());
  239.                 System.out.println("-");
  240.                 d=Double.parseDouble(in.readLine());
  241.                 a=c-d;
  242.                 System.out.println(c+" - "+d+" = "+a);
  243.             }
  244.             else if(o=='C')
  245.             {
  246.                 System.out.println("Enter the two no.s");
  247.                 c=Double.parseDouble(in.readLine());
  248.                 System.out.println("X");
  249.                 d=Double.parseDouble(in.readLine());
  250.                 a=c*d;
  251.                 System.out.println(c+" X "+d+" = "+a);
  252.             }
  253.             else if(o=='D')
  254.             {
  255.                 System.out.println("Enter the two no.s");
  256.                 c=Double.parseDouble(in.readLine());
  257.                 System.out.println("/");
  258.                 d=Double.parseDouble(in.readLine());
  259.                 a=c/d;
  260.                 System.out.println(c+"/"+d+" = "+a);
  261.             }
  262.             else if(o=='E')
  263.             {
  264.                 System.out.println("Enter the two no.s");
  265.                 c=Double.parseDouble(in.readLine());
  266.                 System.out.println("%");
  267.                 d=Double.parseDouble(in.readLine());
  268.                 a=c%d;
  269.                 System.out.println(c+"%"+d+" = "+a);
  270.             }
  271.             else if(o=='F')
  272.             {
  273.                 System.out.println("Enter the number whose square root is to be found");
  274.                 c=Double.parseDouble(in.readLine());
  275.                 a=Math.sqrt(c);
  276.                 System.out.println("Square Root of "+c+" is "+a);
  277.             }
  278.             else if(o=='G')
  279.             {
  280.                 System.out.println("Enter the number whose cube root is to be found");
  281.                 c=Double.parseDouble(in.readLine());
  282.                 a=Math.pow(c,1.0/3.0);
  283.                 System.out.println("Square Root of "+c+" is "+a);
  284.             }
  285.             else if(o=='H')
  286.             {
  287.                 System.out.println("Enter the numbers");
  288.                 c=Double.parseDouble(in.readLine());
  289.                 System.out.println("^");
  290.                 d=Double.parseDouble(in.readLine());
  291.                 a=Math.pow(c,d);
  292.                 System.out.println(c+" raised to "+d+" = "+a+".");
  293.             }
  294.             else
  295.             {
  296.                 System.out.println("The Operator does not exist");
  297.             }
  298.         }
  299.         while(value);
  300.         System.out.println("You have used this program "+b+" times.");
  301.         System.out.println("Thanks for using this program.");
  302.         System.out.println("This program was developed by Spandan Punwatkar aka Salamencizer");
  303.     }
  304.  
  305.     private static void future()throws IOException
  306.     {
  307.         System.out.println("\u000c");
  308.         System.out.println("This is a Future Detector");
  309.         InputStreamReader read = new InputStreamReader(System.in);
  310.         BufferedReader in = new BufferedReader(read);
  311.         char yn=' ';
  312.         int b=1;
  313.         boolean value=false;
  314.         do
  315.         {
  316.             System.out.println("\u000c");
  317.             System.out.println("Enter the name please");
  318.             String nm=in.readLine();
  319.             System.out.println("Please Wait");
  320.             System.out.print(".");
  321.             for(long i=0;i<=500000000;i++)
  322.             {
  323.                 value=false;
  324.             }
  325.             for(long i=0;i<=500000000;i++)
  326.             {
  327.                 if(i%100000000==0)
  328.                     System.out.print("    .");
  329.             }
  330.             System.out.println();
  331.             if(nm.equalsIgnoreCase("Salamencizer") || nm.equalsIgnoreCase("Spandan") || nm.equalsIgnoreCase("Spawn"))
  332.             {
  333.                 System.out.println("#YOLO youre the immortal");
  334.             }
  335.             else
  336.             {
  337.                 System.out.println("Youre gonna die!!");
  338.             }
  339.             System.out.println("Continue lookin for futures??\t\t\t\t\tY/N/yes/no/YES/NO/y/n");
  340.             yn=in.readLine().charAt(0);
  341.             if(yn=='y')
  342.             {
  343.                 b++;
  344.                 value=true;
  345.             }
  346.             else
  347.             {
  348.                 value=false;
  349.             }
  350.         }
  351.         while(value);
  352.         System.out.println("You have used this program "+b+" times.");
  353.         System.out.println("Thanks for using this program.");
  354.     }
  355.  
  356.     private static void grade()throws IOException
  357.     {
  358.         InputStreamReader read = new InputStreamReader(System.in);
  359.         BufferedReader in = new BufferedReader(read);
  360.         System.out.println("This is a Grade finder");
  361.         System.out.print("\u000c");
  362.         float p;
  363.         char yn='w';
  364.         System.out.println("Enter your percentage");
  365.         p=Float.parseFloat(in.readLine());
  366.         if(p>=80 && p<=100)
  367.         {
  368.             System.out.println("Your percentage = "+p);
  369.             System.out.println("Your grade - Distinction");
  370.         }
  371.         else if(p>=60 && p<80)
  372.         {
  373.             System.out.println("Your percentage = "+p);
  374.             System.out.println("Your grade - First class");
  375.         }
  376.         else if(p>=45 && p<60)
  377.         {
  378.             System.out.println("Your percentage = "+p);
  379.             System.out.println("Your grade - Second class");
  380.         }
  381.         else if(p>=40 && p<45)
  382.         {
  383.             System.out.println("Your percentage = "+p);
  384.             System.out.println("Your grade - Pass class");
  385.         }
  386.         else if(p<=0)
  387.         {
  388.             System.out.println("Your percentage = "+p);
  389.             System.out.println("Your grade - Epic Fail");
  390.             System.out.println("wait a minute.....are you yashika?? Y/N");
  391.             yn=in.readLine().charAt(0);
  392.             if(yn=='y'||yn=='Y')
  393.                 System.out.println("I knew it!!");
  394.             else if(yn=='n'||yn=='N')
  395.                 System.out.println("Youre lying!!");
  396.             else
  397.                 System.out.println("Enter Y or N, idiot!");
  398.         }
  399.         else if(p<=40)
  400.         {
  401.             System.out.println("Your percentage = "+p);
  402.             System.out.println("Your grade - Fail");
  403.         }
  404.         else
  405.         {
  406.             System.out.println("Percentage more than 100????");
  407.         }
  408.     }
  409.  
  410.     private static void lettertriangle()throws IOException
  411.     {
  412.         InputStreamReader read = new InputStreamReader(System.in);
  413.         BufferedReader in = new BufferedReader(read);
  414.         System.out.println("\u000c");
  415.         System.out.println("This is a Letter triangle maker");
  416.         System.out.println("ENTER the number of letters( A=1, B=2, and so on)");
  417.         int n=Integer.parseInt(in.readLine());
  418.         //HOLA HOLA WE DEM BOYZ
  419.         for(int i=65;i<=65+n;i++)
  420.         {
  421.             for(int j=65;j<=i;j++) //HOLA HOLA HOLA WE DEM BOYZ
  422.                 System.out.print((char)j+" ");
  423.             System.out.println();
  424.         }
  425.     }
  426.  
  427.     private static void buzz()throws IOException
  428.     {
  429.         InputStreamReader read = new InputStreamReader(System.in);
  430.         BufferedReader in = new BufferedReader(read);
  431.         int n;
  432.         System.out.print("\u000c");
  433.         System.out.println("A buzz number is a number which");
  434.         System.out.println("is divisible by 7 or has 7 in its units place.");
  435.         System.out.println("Enter an integer to check whether it is a buzz no.");
  436.         n=Integer.parseInt(in.readLine());
  437.         if(n>0)
  438.         {
  439.             if(n%7==0 || (n-7)%10==0)
  440.             {
  441.                 System.out.println("This number "+n+" is a buzz no.");
  442.             }
  443.             else
  444.             {
  445.                 System.out.println("This number "+n+" is not a buzz no.");
  446.             }
  447.         }
  448.         else if(n==0)
  449.         {
  450.             System.out.println("0 is not a buzz number");
  451.         }
  452.         else
  453.         {
  454.             if(n%7==0 || (n+7)%10==0)
  455.             {
  456.                 System.out.println("This number "+n+" is a buzz no.");
  457.             }
  458.             else
  459.             {
  460.                 System.out.println("This number "+n+" is not a buzz no.");
  461.             }
  462.         }
  463.     }
  464.  
  465.     private static void reverse()throws IOException
  466.     {
  467.         InputStreamReader read = new InputStreamReader(System.in);
  468.         BufferedReader in = new BufferedReader(read);
  469.         char ch='e';
  470.         System.out.print("\u000c");
  471.         System.out.println("This is a String Reverser");
  472.         System.out.println("Enter the string");
  473.         String y="",x=in.readLine(),s="";
  474.         x=" "+x+" ";
  475.         for(int i=0;i<x.length();i++)
  476.         {
  477.             ch=x.charAt(i);
  478.             if(ch!=' ')
  479.                 y=y+ch;
  480.             if(ch==' ')
  481.             {
  482.                 s=y+" "+s;
  483.                 y="";
  484.                 continue;
  485.             }
  486.         }
  487.         System.out.println("The final is :");
  488.         System.out.println(/*"The final is :"+*/s);
  489.     }
  490.  
  491.     private static void coin()throws IOException
  492.     {
  493.         boolean value=true;
  494.         long baoba=1,ht=0,tt=0;
  495.         InputStreamReader read = new InputStreamReader(System.in);
  496.         BufferedReader in = new BufferedReader(read);
  497.         System.out.println("This is a Coin Tosser");
  498.         do
  499.         {
  500.             System.out.print("\u000c");
  501.             double t=0.0;
  502.             int k=0;
  503.             int h=0;
  504.             long j=0,nexus=0;
  505.             for(int i=0;i<5;i++)
  506.             {
  507.                 t=Math.random();
  508.                 t=t*100;
  509.                 j=(int)t;
  510.                 nexus=j/10;
  511.                 j=j/10;
  512.                 //System.out.println("NEXUS IS NOW "+nexus+" "+);
  513.                 if(nexus%2==0)
  514.                     h++;
  515.                 else
  516.                     k++;
  517.             }
  518.             if(h>k)
  519.             {
  520.                 System.out.println("Tails");
  521.                 ht++;
  522.             }
  523.             else
  524.             {
  525.                 System.out.println("Heads");
  526.                 tt++;
  527.             }
  528.             System.out.println();
  529.             System.out.println();
  530.             System.out.println("Repeat the program??\t\t\t    Y/N/y/n/yep/yeah/no/yes/nope/neva");
  531.             char yn=in.readLine().charAt(0);
  532.             if(yn=='Y'||yn=='y')
  533.             {
  534.                 baoba++;
  535.                 value=true;
  536.             }
  537.             else
  538.                 value=false;
  539.         }
  540.         while(value);
  541.         System.out.println("You have used this program "+baoba+" times.");
  542.         System.out.println("The results are: ");
  543.         System.out.println("Tails obtained "+ht+" times");
  544.         System.out.println("Heads obtained "+tt+" times");
  545.         System.out.println("Thanks for using this program.");
  546.     }
  547.  
  548.     private static void circ()throws IOException
  549.     {
  550.         InputStreamReader read = new InputStreamReader(System.in);
  551.         System.out.println("\u000c");
  552.         System.out.println("Circumference finder");
  553.         BufferedReader in = new BufferedReader(read);
  554.         float r,d;
  555.         double c,a;
  556.         System.out.println("Enter the radius of the circle in centimeters");
  557.         r=Float.parseFloat(in.readLine());
  558.         d=r*2;a=r*r*3.1415926535897932384626433832795;
  559.         c=d*3.1415926535897932384626433832795;
  560.         System.out.println("The radius of the circle = "+r+" cm ");
  561.         System.out.println("The diameter of the circle = "+d+" cm ");
  562.         System.out.println("The circumference of the circle = "+c+" cm (Approximately)");
  563.         System.out.println("The area of the circle = "+a+" (Approximately)");
  564.     }
  565.  
  566.     private static void random5()throws IOException
  567.     {
  568.         boolean baba=true;
  569.         InputStreamReader read = new InputStreamReader(System.in);
  570.         BufferedReader in = new BufferedReader(read);
  571.         long nootimes=1,e=0,o=0;
  572.         while(baba)
  573.         {
  574.             System.out.println("This program will generate 5 random no.s 4 u");
  575.             System.out.print("\u000c")                                                                                    ;
  576.             double t                                                                                                      ;
  577.             int j                                                                                                          ;
  578.             for(int i=0;i<5;i++)
  579.             {
  580.                 t=Math.random()                                                                                            ;
  581.                 t=t*100                                                                                                     ;
  582.                 j=(int) t                                                                                                  ;                                                                                            
  583.                 if((j%10)%2==0)
  584.                     e++;
  585.                 else
  586.                     o++;
  587.                 System.out.println(j%10);
  588.             }
  589.             System.out.println("Repeat the program??\t\t\t    Y/N/y/n/yep/yeah/no/yes/nope/neva");
  590.             char yn=in.readLine().charAt(0);
  591.             if(yn=='Y'||yn=='y')
  592.             {
  593.                 nootimes++;
  594.                 baba=true;
  595.             }
  596.             else
  597.                 baba=false;
  598.         }
  599.         System.out.println("You have used this program "+nootimes+" times.");
  600.         System.out.println("The results are:");
  601.         System.out.println("Even numbers obtained "+e+" times");
  602.         System.out.println("Odd numjbers obtained "+o+" times");
  603.         System.out.println("Thanks for using this program.");
  604.     }
  605.  
  606.     private static String encrypt(String senti)
  607.     {
  608.         String sent="";
  609.         senti=senti.toUpperCase();
  610.         char a[]=new char[26];
  611.         char []b=new char[26];int l=0;
  612.         for(int i=0;i<26;i++)
  613.             a[i]=(char)(i+65);
  614.         for(int i=(int)'Z';i>=(int)'A';i--)
  615.         {
  616.             b[l]=(char)i;
  617.             l++;
  618.         }
  619.         for(int i=0;i<senti.length();i++)
  620.             if(Character.isLetter(senti.charAt(i)))
  621.             {
  622.                 for(int j=0;j<=25;j++)
  623.                     if(senti.charAt(i)==a[j])
  624.                         sent=sent+b[j];
  625.             }
  626.             else
  627.                 sent=sent+senti.charAt(i);
  628.         return sent;
  629.     }
  630.  
  631.     private static void randprog()throws IOException
  632.     {
  633.         InputStreamReader read = new InputStreamReader(System.in);
  634.         BufferedReader in = new BufferedReader(read);
  635.         boolean baba=false;
  636.         int progno=0,gel=0,nootimes=1;
  637.         do
  638.         {
  639.             System.out.print("\u000c");
  640.             System.out.println("Take you to a random program?\t\t\tY/N/y/n/yep/yeah/no/yes/nope/neva");
  641.             char yno=in.readLine().charAt(0);
  642.             if(yno=='Y'||yno=='y')
  643.             {
  644.                 progno = random();
  645.                 if(progno==0)
  646.                     calculator();
  647.                 else if(progno==1)
  648.                     future();
  649.                 else if(progno==2)
  650.                     grade();
  651.                 else if(progno==3)
  652.                     lettertriangle();
  653.                 else if(progno==4)
  654.                     buzz();
  655.                 else if(progno==5)
  656.                     reverse();
  657.                 else if(progno==6)
  658.                     coin();
  659.                 else if(progno==7)
  660.                     circ();
  661.                 else if(progno==8)
  662.                     random5();
  663.                 else if(progno==9)
  664.                 {
  665.                     boolean baoba=false;
  666.                     long noo=1;
  667.                     do
  668.                     {
  669.                         String sent="",cord="";
  670.                         System.out.print("\u000c");
  671.                         System.out.println("-----------------------------------------------------");
  672.                         System.out.println("Welcome to the code generator. What do you wanna do? |");
  673.                         System.out.println("-----------------------------------------------------");
  674.                         System.out.println(" ---->Transform a sentence to a code\tEnter transform");
  675.                         System.out.println("");
  676.                         System.out.println(" ---->Decode a code sentence        \tEnter Decode");
  677.                         System.out.println("");
  678.                         char wtd= ((in.readLine()).toUpperCase()).charAt(0);
  679.                         if(wtd=='T')
  680.                         {
  681.                             System.out.println("Enter the sentence to be transformed. (EVERTHING MUST BE CAPS)");
  682.                             sent=in.readLine();
  683.                             cord=encrypt(sent);
  684.                             System.out.println(" *****Transformation completed!! The code is: *****");
  685.                             System.out.println(cord);
  686.                         }
  687.                         else if(wtd=='D')
  688.                         {
  689.                             System.out.println("Enter the sentence to be decoded. (EVERTHING MUST BE CAPS)");
  690.                             sent=in.readLine();
  691.                             cord=encrypt(sent);
  692.                             System.out.println(" *****Decoding completed!! The code is: *****");
  693.                             System.out.println(cord);
  694.                         }
  695.                         else
  696.                         {
  697.                             System.out.println("Sorry, enter something valid!!");
  698.                         }
  699.                         System.out.println("Repeat the program??\t\t\t    Y/N/y/n/yep/yeah/no/yes/nope/neva");
  700.                         char yn=in.readLine().charAt(0);
  701.                         if(yn=='Y'||yn=='y')
  702.                         {
  703.                             noo++;
  704.                             baoba=true;
  705.                         }
  706.                         else
  707.                             baoba=false;
  708.                         System.out.print("\u000c");
  709.                     }
  710.                     while(baoba);
  711.                     System.out.println("You have used this program "+noo+" times.");
  712.                     System.out.println("Thanks for using this program.");
  713.                 }
  714.             }
  715.             else
  716.                 System.out.println("Okay!");
  717.             System.out.println("You have returned to the Random Programinator");
  718.             System.out.println("Repeat the program??\t\t\t    Y/N/y/n/yep/yeah/no/yes/nope/neva");
  719.             yno=in.readLine().charAt(0);
  720.             if(yno=='Y'||yno=='y')
  721.             {
  722.                 nootimes++;
  723.                 baba=true;
  724.             }
  725.             else
  726.                 baba=false;
  727.             System.out.print("\u000c");
  728.         }
  729.         while(baba);
  730.         System.out.println("You have used this program "+nootimes+" times.");
  731.         System.out.println("Thanks for using this program.");
  732.     }
  733.  
  734.     private static String dre(String sent)
  735.     {
  736.         sent=sent.toUpperCase();
  737.         char a[]=new char[26];
  738.         char b[]=new char[26];int k=65;
  739.         String news="";
  740.         for(int i=0;i<26;i++,k++)
  741.             a[i]=(char)k;
  742.         k=(int)'N';
  743.         for(int i=0;i<13;i++,k++)
  744.             b[i]=(char)k;
  745.         k=(int)'A';
  746.         for(int i=13;i<26;i++,k++)
  747.             b[i]=(char)k;
  748.         for(int i=0;i<sent.length();i++)
  749.         {
  750.             char t=sent.charAt(i);
  751.             if(Character.isLetter(t))
  752.             {
  753.                 for(int j=0;j<=25;j++)
  754.                     if(t==a[j])
  755.                         news=news+b[j];
  756.             }
  757.             else
  758.                 news=news+t;
  759.         }
  760.         return news;
  761.     }
  762. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement