⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mathops.java

📁 java编程思想的部分实现
💻 JAVA
字号:
import java.util.*;

public class MathOps
{
	//Create a shorthand to save typing:
	static void Prt(String s)
	{
		System.out.println(s);
	}
	//shorthand to print a string ang an int:
	static void pInt(String s,int i)
	{
		Prt(s+"="+i);
	}
	//shorthand to print a string and a float:
	static void pFlt(String s,float f)
	{
		Prt(s+"="+f);
	}
	public static void main(String [] args)
	{
		//create a random number generator,seeds with current time by default;
		Random rand=new Random();
		int i,j,k;
		//'%'limits maximum value to 99:
		j=rand.nextInt()%100;
		k=rand.nextInt()%100;
		pInt("j",j);
		pInt("k",k);
		i=j+k;
		pInt("j+k",i);
		i=j-k;
		pInt("j-k",i);
		i=k/j;
		pInt("k/j",i);
		i=k*j;
		pInt("k*j",i);
		i= k&j;
		pInt("k&j",i);
		j&=k;
		pInt("j&=k",j);
		//floating-point number tests:
		float u,v,w;
		//applies to doubles,too
		v=rand.nextFloat();
		w=rand.nextFloat();
		pFlt("v",v);
		pFlt("w",w);
		u=v+w;
		pFlt("v+w",u);
		u=v-w;
		pFlt("v-w",u);
		u=v*w;
		pFlt("v*w",u);
		u=v/w;
		pFlt("v/w",u);
		//the following also works for char,byte,short,int,long,and double:
		u+=v;
		pFlt("u+=v",u);
		u-=v;
		pFlt("u-=v",u);
		u*=v;
		pFlt("u*=v",u);
		u/=v;
		pFlt("u/=v",u);
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -