Start New Discussion within our Software Development Community

I have to design a program that uses Basic Math class. With the following functions and imput commands Add (Add), Substract (Sub), Multiply (Mult), Divide (Div), Exponents, ie. 2^3 (Exp), and Factorial, ie. 3! (Fact).

So far I have this, i just can't figure out how to add the functions.

/**
* Basic Math class
*/

import java.io.*;

class basicMath
{
private static String instructions = "Enter the (imput command) followed by " +
"the numbers, Z = X imput command Y.\n";

public static void main (String[] argv)
{
int X, Command, Y;
int Z;

System.out.println (instructions);
System.out.println ("Enter X: ");
X = getN();
System.out.println ("Command: ");
Command = getN();
System.out.println ("Enter Y: ");
Y = getN();
System.out.println ("Result is: ");

}

static int Comman (int Add, int Sub, int Mult, int Div)

{
int commanOut;

if (Add)
{
commanOut = X += Y;
return (commanOut);
}
}

private static int getN ()
{
int inputInt = 1;
BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
String inStr;
try
{
inStr = in.readLine ();
inputInt = Integer.parseInt(inStr);
}
catch (IOException e)
{
System.out.println ("Could not read input.");
}
catch (NumberFormatException e)
{
System.out.println ("Entry must be a number.");
}
return (inputInt);
}


}

PLEASE HELP, I am getting really frustrated, i have to finish by wednesday. And my mind just can't handle it.

Anythings helps

This article has been dead for over six months. Start a new discussion instead.