Member: Li Guibin.
Import Java.text.DecimalFormat;
Import Java.util.Scanner;
public class F {
public static void Main (string[] args) {
String condition = "";
F Zhidao = new F ();
do{
Scanner Scanner = new Scanner (system.in);
try{
System.out.print ("Please enter the first number:");
Double x = scanner.nextdouble ();
System.out.print ("Please enter a second number:");
Double y = scanner.nextdouble ();
System.out.print ("Please enter operator:");
String s = scanner.next ();
Char z = s.charat (0);
Zhidao.yunsuan (x, y, z);
}catch (Exception e) {
System.out.println ("Please enter the correct data!") ");
}
System.out.print ("Do you want to continue?" Continue: Continue, any character: End ");
Condition = Scanner.next ();
}while ("Continue". Equals (condition));
}
public static void Yunsuan (double x,double y,character z) {
DecimalFormat r=new DecimalFormat ();
R.applypattern ("#0.00");
if (z.equals (' + ')) {
System.out.println (x+ "+" +y+ "=" + R.format ((x+y)));
} else if (Z.equals ('-')}) {
System.out.println (x+ "-" +y+ "=" + R.format (x-y));
} else if (z.equals (' * ')) {
SYSTEM.OUT.PRINTLN (x+ "*" +y+ "=" + R.format ((x*y)));
} else if (z.equals ('/')) {
if (y==0) {
SYSTEM.OUT.PRINTLN ("Dividend cannot be 0");
} else{
System.out.println (x+ "/" +y+ "=" + R.format (x/y));
}
}else{
SYSTEM.OUT.PRINTLN ("This operator is not recognized");
}
}
}
The above is addition;
The above is multiplication;
Please enter the first number: 7
Please enter a second number: 1
Please enter operator:/
7.0/1.0=7.00
Do you want to continue? Continue: Continue, any character: end
The above is division;
Please enter the first number: 8
Please enter a second number: 2
Please enter operator:-
8.0-2.0=6.00
Do you want to continue? Continue: Continue, any character: end
The above is subtraction;
Summary: The job, I really did the full effort, did two days to complete, specific time-consuming no statistics, hope the teacher understanding. And for our poor grades are not willing to take to do, only their own slowly to do so to pay a little late look at the teacher understanding. Can do this step really feel very hard, but overall harvest is very great and a sense of accomplishment.
Third job of software engineering