Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Hello World
- import java.util.Scanner;
- public class HelloWorld {
- public static void main(String[] args){
- Scanner keyboard = new Scanner(System.in);
- System.out.println("Hello World");
- System.out.println("My name is Supercomputer\n");
- System.out.print("What is your name? ");
- String name;
- name = keyboard.nextLine();
- if((name.equals("Supercomputer")) || name.equals("supercomputer")){
- System.out.println(name + "?!?!? Copycat!!!");
- } else{
- System.out.println("Wow! " + name + " is a nice name!");
- }
- System.out.println("I'm really good at math. \nDo you need help with a simple arithmithic problem?");
- String yesNo = "";
- while(!(yesNo.equals("No") || yesNo.equals("no") || yesNo.equals("Yes") || yesNo.equals("yes"))){
- yesNo = keyboard.nextLine();
- if(yesNo.equals("No") || yesNo.equals("no")){
- System.out.println("Okay! Loser!");
- } else if(yesNo.equals("Yes") || yesNo.equals("yes")){
- 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!");
- String as = "";
- 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"))){
- as = keyboard.nextLine();
- if(as.equals("A") || as.equals("a")){
- System.out.println("Please enter two digits to add.");
- int x;
- System.out.print("Please enter the first digit: ");
- x = keyboard.nextInt();
- int z;
- System.out.print("Please enter the second digit: ");
- z = keyboard.nextInt();
- int y = x + z;
- System.out.println("The answer is: " + y);
- } else if(as.equals("S") || as.equals("s")){
- int x;
- System.out.println ("Please enter the first digit: ") ;
- x = keyboard.nextInt();
- int z;
- System.out.print("Please enter the second digit:");
- z = keyboard.nextInt();
- int y = x - z ;
- System.out.println("The answer is " + y);
- } else if (as.equals("m") || as.equals("M")) {
- int x;
- System.out.print("Please enter the first digit: ");
- x = keyboard.nextInt();
- int z;
- System.out.print("Please enter the second digit: ");
- z = keyboard.nextInt();
- int y = x * z;
- System.out.println("The answer is " + y);
- } else if (as.equals("d") || as.equals ("D")) {
- float x;
- System.out.print("Please enter the first digit: ");
- x = keyboard.nextFloat();
- float z;
- System.out.print("Please enter the second digit: ");
- z = keyboard.nextFloat();
- float y = x / z;
- System.out.println("The answer is " + y);
- } else {
- System.out.println("Please enter an 'A' or a 'S' or a 'M' or a 'D'");
- }
- }
- } else {
- System.out.println("Sorry, that's not a yes or no, please enter a yes or no");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment