Guest User

Untitled

a guest
Jun 8th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.73 KB | None | 0 0
  1. //Hello World
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class HelloWorld {
  6.    public static void main(String[] args){
  7.          Scanner keyboard = new Scanner(System.in);
  8.          System.out.println("Hello World");
  9.          System.out.println("My name is Supercomputer\n");
  10.          System.out.print("What is your name? ");
  11.          String name;
  12.          name = keyboard.nextLine();
  13.          if((name.equals("Supercomputer")) || name.equals("supercomputer")){
  14.             System.out.println(name + "?!?!? Copycat!!!");
  15.          } else{
  16.              System.out.println("Wow! " + name + " is a nice name!");
  17.          }
  18.          System.out.println("I'm really good at math. \nDo you need help with a simple arithmithic problem?");
  19.          String yesNo = "";
  20.          while(!(yesNo.equals("No") || yesNo.equals("no") || yesNo.equals("Yes") || yesNo.equals("yes"))){
  21.             yesNo = keyboard.nextLine();
  22.             if(yesNo.equals("No") || yesNo.equals("no")){
  23.                System.out.println("Okay! Loser!");
  24.             } else if(yesNo.equals("Yes") || yesNo.equals("yes")){
  25.                System.out.println("I can do addition, multiplication, division, or subtraction! Type 'A' for addition, 'M' for Multiplication, 'D' for division, and 'S' for subtraction!");
  26.                String as = "";
  27.                while(!(as.equals("A") || as.equals("a") || as.equals("s") || as.equals("S") || as.equals ("M") || as.equals ("m") || as.equals ("d") || as.equals("D"))){
  28.                   as = keyboard.nextLine();
  29.                   if(as.equals("A") || as.equals("a")){
  30.                      System.out.println("Please enter two digits to add.");
  31.                      int x;
  32.                      System.out.print("Please enter the first digit: ");
  33.                      x = keyboard.nextInt();
  34.                      int z;
  35.                      System.out.print("Please enter the second digit: ");
  36.                      z = keyboard.nextInt();
  37.                      int y = x + z;
  38.                      System.out.println("The answer is: " + y);
  39.                   } else if(as.equals("S") || as.equals("s")){
  40.                      int x;
  41.                      System.out.println ("Please enter the first digit: ") ;
  42.                      x = keyboard.nextInt();
  43.                      int z;
  44.                      System.out.print("Please enter the second digit:");
  45.                      z = keyboard.nextInt();
  46.                      int y = x - z ;
  47.                      System.out.println("The answer is " + y);
  48.                   } else if (as.equals("m") || as.equals("M")) {
  49.                      int x;
  50.                      System.out.print("Please enter the first digit: ");
  51.                      x = keyboard.nextInt();
  52.                      int z;
  53.                      System.out.print("Please enter the second digit: ");
  54.                      z = keyboard.nextInt();
  55.                      int y = x * z;
  56.                      System.out.println("The answer is " + y);
  57.  
  58.                   } else if (as.equals("d") || as.equals ("D")) {
  59.                      float x;
  60.                      System.out.print("Please enter the first digit: ");
  61.                      x = keyboard.nextFloat();
  62.                      float z;
  63.                      System.out.print("Please enter the second digit: ");
  64.                      z = keyboard.nextFloat();
  65.                      float y = x / z;
  66.                      System.out.println("The answer is " + y);  
  67.                  
  68.                   } else {
  69.                      System.out.println("Please enter an 'A' or a 'S' or a 'M' or a 'D'");
  70.                   }
  71.               }
  72.             } else {
  73.                System.out.println("Sorry, that's not a yes or no, please enter a yes or no");
  74.             }
  75.          }
  76.    }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment