. Write a program which ask the user to enter a series of integers and the series should end with the integer â??0â?? and display the sum and average of integers
import java.util.Random;
import java.io.*;
public class Primenumber {
public static void main(String args[])
{
try
{
int number=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the number of threads to be created \n");
number=Integer.parseInt(br.readLine());
for(int index=0;index<number;index++)
{
Primeno P=new Primeno();
P.primenum();
}
}catch(Exception e){}
}
}
class Primeno extends Thread
{ void primenum()
{
start();
}
public void run(){
Random randomGenerator=new Random();
int randomInt=randomGenerator.nextInt(20);
//String name=Primeno.currentThread(); System.out.println("the current thread in execution is"+Primeno.currentThread());
System.out.println("The upperlimit of"+Primeno.currentThread()+ "prime no is"+randomInt);
for(int index=2;index<randomInt;index++)
{
if(isPrime(index))
System.out.println("ThreadName:"+Primeno.currentThread().getName()+" "+index);
Try
{
sleep(1000);
}
catch(InterruptedException e){
System.out.println(e);
}
}//end of for loop
}//end of run method
public boolean isPrime(int num) {
boolean prime=true;
int limit=(int)Math.sqrt(num);
for(int index=2;index<=limit;index++)
{
if(num%index==0){ prime=false; break;
}
}
return prime;
}
}//end of thread prime number
public class Excercise1{
public static int x = 7;
public int y=3;
}
Question: what are the class variables? what are the instance variables?
2.Determine
the error in the program segmet below.
public class Exercise2{
public static void main(String [] args){
Rectangle myRect;
myRect.width = 40;
my Rect.height = 50;
system.out.println("Rectangle's area is " + myRect.area(();
}
}
javamufeeza October 4, 2011 at 10:47 AM
. Write a program which ask the user to enter a series of integers and the series should end with the integer â??0â?? and display the sum and average of integers
c code :Narmadha November 3, 2011 at 9:18 AM
How can i print * * * * * * * * ** ** ** *
java program (explanatiosuvarna December 4, 2011 at 4:19 PM
import java.util.Random; import java.io.*; public class Primenumber { public static void main(String args[]) { try { int number=0; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter the number of threads to be created \n"); number=Integer.parseInt(br.readLine()); for(int index=0;index<number;index++) { Primeno P=new Primeno(); P.primenum(); } }catch(Exception e){} } } class Primeno extends Thread { void primenum() { start(); } public void run(){ Random randomGenerator=new Random(); int randomInt=randomGenerator.nextInt(20); //String name=Primeno.currentThread(); System.out.println("the current thread in execution is"+Primeno.currentThread()); System.out.println("The upperlimit of"+Primeno.currentThread()+ "prime no is"+randomInt); for(int index=2;index<randomInt;index++) { if(isPrime(index)) System.out.println("ThreadName:"+Primeno.currentThread().getName()+" "+index); Try { sleep(1000); } catch(InterruptedException e){ System.out.println(e); } }//end of for loop }//end of run method public boolean isPrime(int num) { boolean prime=true; int limit=(int)Math.sqrt(num); for(int index=2;index<=limit;index++) { if(num%index==0){ prime=false; break; } } return prime; } }//end of thread prime number
please gie the answer immediatelytsaranya December 7, 2011 at 5:12 PM
my pblm is how to create edit button in a perticular row after update that datas
javaamit kumar saini February 24, 2012 at 12:26 PM
My question this,What is different between Enumeration and Iterator Interface?
javaamit kumar saini February 24, 2012 at 12:30 PM
what is JVM?And can we call JVM is Software and what is work it?
RedBlackTree in JPanel with graphical notationvivek upadhyay April 14, 2012 at 2:27 AM
how to follow its property
Relation of numbersudipta sekhar mahapatra December 17, 2012 at 6:04 PM
i would like to know about making java script programme
jsp and servlet calculatorncebayakhe September 13, 2012 at 7:14 PM
I want a code for calculator in html,jsp and servlet
Please help me solve thisChacha November 25, 2012 at 5:35 PM
public class Excercise1{ public static int x = 7; public int y=3; } Question: what are the class variables? what are the instance variables? 2.Determine the error in the program segmet below. public class Exercise2{ public static void main(String [] args){ Rectangle myRect; myRect.width = 40; my Rect.height = 50; system.out.println("Rectangle's area is " + myRect.area((); } }
Post your Comment