Job 5 test and package arithmetic

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.