Pages

Sabtu, 26 November 2011

Source code -Voting menggunakan Java





JAVA FILE


import java.util.Scanner;


public class e_lection
 {
  public static void main(String[] args)
 {
  Scanner input=new Scanner(System.in);


  int x;
  int y,y1,y2,y3,y4,y5,y6;
  int []pilih=new int[100];


  for(x=1; x<=10; x++)


{
   System.out.println(" 1. Mr.Black ,  2. Mr.White  , 3. Mr.yellow , 4. Mr. Dark");
   System.out.println(" 5. Ms.Tee   ,  6. Ms.Tea    , 7. Ms. milk");
   System.out.println("Masukan para kandidat : ");
   pilih[x]=input.nextInt();         
      }
y=0;
y1=0;
y2=0;
y3=0;
y4=0;
y5=0;
y6=0;
 for(x=1; x<=10; x++)
 {
    if(pilih[x]==1)
     y=y+pilih[x];


         if(pilih[x]==2)
     y1=y1+pilih[x];


    if(pilih[x]==3)
     y2=y2+pilih[x];


         if(pilih[x]==4)
     y3=y3+pilih[x];


    if(pilih[x]==5)
     y4=y4+pilih[x];


         if(pilih[x]==6)
     y5=y5+pilih[x];


    if(pilih[x]==7)
     y6=y6+pilih[x];
}
System.out.println("RESULT OF VOTE");
System.out.println("Black :"+ y);
System.out.println("White :"+ y1/2);
System.out.println("Yellow:"+ y2/3);
System.out.println("Dark  :"+ y3/4);
System.out.println("Tee   :"+ y4/5);
System.out.println("Tea   :"+ y5/6);
System.out.println("Milk  :"+ y6/7);
}
}
/*success, test 7.11.11 , 17.00 pm
  resistance
  joexce
  CMD ENGINE WIN 7 32 BIT
*/

0 komentar:

Posting Komentar