Ok heres the story i took i havent done java for a year and im way behind but manage to getthe programs done just but im never happ with them. If any one could see if they could improve this one (its allready been marked its just to see how otheres might finish it off that im curios about) (also is there a command in java when the program is activated that it does a cls?) heres the code ive done and is marked.
import java.io.*;
public class arithmetic {
public static void main (String [] args) throws IOException {
int num1 = 0;
int num2 = 0;
String retry = "yes";
char op = ' ';
BufferedReader kbd = new BufferedReader (new InputStreamReader (System.in));
Double ddd; //Double Wrapper Class
while (retry.equals("yes")){
System.out.println ("\n\n................................................................");
System.out.println ("\nEnter your first number:");
num1 = Integer.parseInt (kbd.readLine () );
if (num1 > 100 )
System.out.println("\nOnly numbers that are between 1 and 100 will be considered as a valid number.\n\n Please enter a valid number:");
while (num1 >100){
num1 = Integer.parseInt (kbd.readLine () );
}
System.out.println ("\nEnter your second number:");
num2 = Integer.parseInt (kbd.readLine () );
if (num2 > 100 )
System.out.println("\nOnly numbers that are between 1 and 100 will be considered as a valid number.\n\n Please enter a valid number:");
while (num2 >100){
num2 = Integer.parseInt (kbd.readLine () );
}
System.out.println ("\nPlease enter one of the following signs * or / or - or + ");
op = (char) kbd.read ();
kbd.readLine ();
while (op != '+' && op != '-' && op != '*' && op != '/') {
System.out.println("The only characters that will be excepted are + - * / enter one of these");
op = (char) kbd.read ();
kbd.readLine ();
}
if (op=='/') {
System.out.println("Result:" + (num1 / num2));
} else if (op=='*') {
System.out.println("Result:" + (num1 * num2));
} else if (op=='-') {
System.out.println("Result:" +(num1 - num2));
} else if(op=='+') {
System.out.println("Result:" +(num1 + num2));
}
System.out.println("Do you want to try another equation?:(yes/exit)");
retry = kbd.readLine ();
} }
}
Any ideas?