码迷,mamicode.com
首页 > 其他好文 > 详细

四则运算

时间:2017-12-02 20:21:40      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:运算   system   style   oid   ati   技术分享   分享图片   main   print   

1.源代码

package 四则运算;
//信1605-1张迪20163480
public class math {
     private int a,b,c,d;
     String f;
    
     public void set()
     {
         a=(int)(Math.random() * 99 + 1);
         b=(int)(Math.random() * 99 + 1);
         c=(int)(Math.random() * 3 + 1);
         
     } 
     public void result() {
         if(c==1)
         {
            
             System.out.println(a+"+"+b+"=");
         }
         else if(c==2)
         {
             System.out.println(a+"-"+b+"=");
         }
         else if(c==3)
         {
             System.out.println(a+"*"+b+"=");
         }
         else
         {
             System.out.println(a+"/"+b+"=");
         }
     }
   
     public static void main(String[] args) {
        math A=new math();
        for(int i=1;i<=60;i++)
        {
            A.set();
            A.result();
        }
        
     }
}

2.截图

技术分享图片

 

四则运算

标签:运算   system   style   oid   ati   技术分享   分享图片   main   print   

原文地址:http://www.cnblogs.com/sunshine-z/p/7955332.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!