# help me please this is a calculator by the way

• May 8th, 2014, 04:39 PM
ryry163
help me please this is a calculator by the way
What did I do wrong here? I was trying to make a calculator for my AP Comp Science class and it turned out now to work.. I followed the teachers instructions but it didn't work. Does anyone have any suggestions on how to fix this?Thanks :)

Code java:

```import java.util.*;   public class d { public static void main(String[] args) { /*Scanner input = new Scanner(System.in); System.out.println("What are you doing?"); if (answer.equalsIgnorecase("multiplication")) { Multiplication(); }*/ System.out.println("Hello, If you are doing Multiplication Type 1."); System.out.println("If you are doing Addition, Type 2."); System.out.println("If you are doing Subtraction, Type 3"); System.out.println("If you are doing Division, Type 4"); Scanner input = new Scanner(System.in); int decision; decision = input.nextInt(); if (decision == 1) { Multiplication(); } if (decision == 2) { Addition(); } if (decision == 3) { Subtraction(); } if (decision == 4) { Division(); } else { System.out.println("Those aren't valid numbers."); } }     } public static void Multiplication() { int mInput1; int mInput2;   Scanner input = new Scanner(System.in); System.out.print("What is the first number? "); mInput1 = input.nextInt();   System.out.print("What is the second number? "); mInput2 = input.nextInt();   System.out.println(mInput1 + " times " + mInput2 + " equals " + mInput1 * mInput2); } public static void Addition() { int aInput1; int aInput2; int aAnswer;   Scanner input = new Scanner(System.in); System.out.println("What is the first number?"); aInput1 = input.nextInt();   System.out.println("What is the second number?"); aInput2 = input.nextInt();   aAnswer = aInput1 + aInput2; System.out.println(aInput1 + " plus " + aInput2 + " equals " + aAnswer); } public static void Subtraction() { int sInput1; int sInput2; int sAnswer;   Scanner input = new Scanner(System.in); System.out.println("What is the first number?"); sInput1 = input.nextInt();   System.out.println("What is the second number?"); sInput2 = input.nextInt();   sAnswer = sInput1 - sInput2; System.out.println(sInput1 + " minus " + sInput2 + " equals " + sAnswer); } public static void Division() { int dInput1; int dInput2; int dAnswer;   Scanner input = new Scanner(System.in); System.out.println("What is the first number?"); dInput1 = input.nextInt();   System.out.println("What is the second number?"); dInput2 = input.nextInt();   dAnswer = dInput2 / dInput1; System.out.println(dInput1 + " divided by " + dInput2 + " equals " + dAnswer); } }```
• May 8th, 2014, 04:47 PM
Norm
Re: help me please this is a calculator by the way
Quote:

What did I do wrong here

The first problem I see is the classname. d????

Please edit your post and wrap your code with code tags:
[code=java]
[/code]
to get highlighting and preserve formatting.
• May 8th, 2014, 04:58 PM
ryry163
Re: help me please this is a calculator by the way
Oh thank you I fixed it... First time here...
• May 8th, 2014, 05:02 PM
Norm
Re: help me please this is a calculator by the way
Quote:

it didn't work