- 论坛徽章:
- 0
|
import java.lang.Math;
public class J_Prime
{
public int number;
public int prime;
public int sum;
J_Prime(int x,int y,int z)
{
mb_set(0,0,0);
}
public void mb_set(int x,int y,int z)
{
number=x;
prime=y;
sum=z;
}
public void mb_prime()
{
for(prime=0;prime<=100;prime+=2)
{
int i;
number=Math.sqrt(prime);
for(i=0;i<=number;i++)
if(i%prime==0)break;
if(i>number+1)
System.out.println("the prime numbers in 0--100 are"+prime);
}
}
public void mb_sum()
{
int i;
for(i=0;i<=number;i++)
sum+=sum;
System.out.println("the prime numbers' sum is"+sum);
}
public static void main(String args[])
{
J_Prime a=new J_Prime(0,0,0);
a.mb_prime();
a.mb_sum();
}
}
////////////
报错如下:
D:/myfile>javac J_Prime.java
j+prime.java:26:possible loss of precision
found :double
required :int
number=Math.sqrt(prime);
^
1 error |
|