Trying to make a simple english text calculator and i keep getting some errors. Here is what i have
/*
* A calculator that calculates your answer and outputs it i english.
*/
package Calc;
/**
*
* @author Austin
*/
import java.text.*;
import java.util.Scanner;
public class Calc {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Declaration
Scanner scan = new Scanner(System.in);
int Num1, Num2, Result;
String Num1S, Num2S, OperationS;
char operations;
boolean Num1OK=true, Num2OK=true, operationsOK=true;
//Inputs
System.out.print("Enter your first number ");
Num1 = scan.nextInt();
{
if (Num1 > 9 || Num1 < 0)
System.out.println(" Must be a Number between 0 and 9");
}
System.out.print("Enter your second number ");
Num2 = scan.nextInt();
{
if (Num2 > 9 || Num2 < 0)
System.out.println(" Must be a Number between 0 and 9");
}
// Prompt
System.out.println("\nEnter one of the operations +,-,*,/,^");
operations = scan.next().charAt(0);
//Operation and results
switch(Num1)
{
case 0:
Num1S="zero";
case 1:
Num1S="one";
case 2:
Num1S="two";
case 3:
Num1S="three";
case 4:
Num1S="four";
case 5:
Num1S="five";
case 6:
Num1S="six";
case 7:
Num1S="seven";
case 8:
Num1S="eight";
case 9:
Num1S="nine";
Num1OK=false;
}
switch(Num2)
{
case 0:
Num2S="zero";
case 1:
Num2S="one";
case 2:
Num2S="two";
case 3:
Num2S="three";
case 4:
Num2S="four";
case 5:
Num2S="five";
case 6:
Num2S="ix";
case 7:
Num2S="seven";
case 8:
Num2S="eight";
case 9:
Num2S="nine";
Num2OK=false;
}
switch (operations)
{
case '+':
OperationS=" plus" ;
Result = Num1 + Num2;
case '-':
OperationS=" minus" ;
Result = Num1 - Num2;
case '*':
OperationS=" multiplied by " ;
Result = Num1 * Num2;
case '/':
OperationS=" divided by " ;
Result = Num1 / Num2;
case '^':
OperationS=" to the power of" ;
Result = (int) (Math.pow(Num1, Num2));
operationsOK=false;
}
{
System.out.println(+ Num1 + OperationS + + Num2 + " is " + Result +););
}
I need to some how get it to out put like this.
Five plus six is 11
I also need it to not allow you to enter anything below 0 or above 9
and if you enter a character that isnt an operation to output a message. im missing just a few things i blieve/hope! let me know