package com.gg.test;
import java.util.Scanner;
public class figure {
public static void main(String[] args) {
Math math=new Math();
@SuppressWarnings("resource")
Scanner scanner =new Scanner(System.in);
System.out.println("请输入第一个数!!!:\n");
System.out.println("输入完成后请按回车键!");
math.setNum1(scanner.nextInt());
System.out.println("请输入第二个数!!!:\n");
System.out.println("输入完成后请按回车键!");
math.setNum2(scanner.nextInt());
System.out.println("↓以下就是你需要孟哥帮你算的所有结果↓");
System.out.println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓");
System.out.println("***************************\n");
math.addition();
math.subtraction();
math.Multiplication();
math.division();
System.out.println("***************************\n");
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public String toString() {
return "Math [num1=" + num1 + ", num2=" + num2 + "]";
}
public Math(double num1, double num2) {
super();
this.num1 = num1;
this.num2 = num2;
}
public Math() {
super();
// TODO 自动生成的构造函数存根
}
public void addition(){
System.out.println("你的加法结果是"+(num1+num2));
}
public void subtraction(){
System.out.println("你的减法结果是"+(num1-num2));
}
public void Multiplication(){
System.out.println("你的乘法结果是"+num1*num2);
}
public void division(){
if(num2==0){
System.out.println(" 警告?不许输入为零的被除数!!");
}
else{
System.out.println("你的除法结果是"+num1/num2);
}
}
public double getNum1() {
return num1;
}
public void setNum1(double num1) {
this.num1 = num1;
}
public double getNum2() {
return num2;
}
public void setNum2(double num2) {
this.num2 = num2;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
}
原文地址:https://www.cnblogs.com/JachinMeng/p/9688776.html