Package Aaa;import Java.text.decimalformat;import Java.util.scanner;public class Dada {public static void main (string[] args) {int condition=1;D ada Dada = new Dada (); Scanner Scanner = new Scanner (system.in), while (condition==1) {System.out.print ("Please enter first number:");d ouble x = Scanner.nextdouble (); System.out.print ("Please enter a second number:");d ouble y = scanner.nextdouble (); System.out.print ("Please enter operator:"); String s = scanner.next (); char z = s.charat (0); Test test=new test (); Test.yunsuan (x, y, z); System.out.print ("Do you want to continue?" 1 is other for No "); condition = Scanner.nextint ();}}} Package Aaa;import Java.text.decimalformat;public class test{public static void Yunsuan (double x,double y,character z) { DecimalFormat r=new DecimalFormat (); R.applypattern ("#0. xx"), 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 ("unrecognized modifier");}}}
Did not find the small partner, because many students have gone back. This is a small program I do, although not many features, but this program has a lot to improve and can add a lot of features.
Job 5 test and package arithmetic