Ring




import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Ring {
static int n,pc,in;
static String s;
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader (System.in));
System.out.println("Enter the Number of Clients");
n=Integer.parseInt(br.readLine());
System.out.println("Enter the Pri-Coordinator");
pc=Integer.parseInt(br.readLine());
System.out.println("Enter the Introducer");
in=Integer.parseInt(br.readLine());
s="";
for(int i=in;;)
{
System.out.print(i+"Send the Election messege to ");
s=s+i;
i=i+1;
if(i==pc)
i=i+1;
if(i>n)
i=1;
System.out.print(i+" The messege is "+s+"\n");
if(i==in)
break;
}
for(int i=n;i>=1;i--)
{
if(i!=pc && i>=i-1)
{
System.out.println("The new Co-ordinator is Selected."+i);
pc=i;
break;
}

}
for(int i=1;i<=n;i++)
{
if(i!=pc)
System.out.println("The new Co-ordinator "+pc+" is Send the ok Messege to ."+i);
}
}
}




Leave a Reply