Third job of software engineering

Source: Internet
Author: User

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

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.