// Voting program app by Raghavan
import java.util.*;
class my{
static Scanner sc=new Scanner(System.in);
static void input_stuff() {
System.out.println("Enter the number of candidates");
int no_of_candidate=sc.nextInt();
System.out.println("Enter the name of the candidate");
String name_of_candidate[]=new String[no_of_candidate];
for (int i=0;i<no_of_candidate;i++) {
name_of_candidate[i]=sc.next();
}
vote(name_of_candidate,no_of_candidate);
}
static void vote(String name[],int n) {
String total[]= {"Raghavan","Jagarnath","Manish","Manish K","Shiwam","Nikhil","Navin","Binod","Ankit","Mohit"};
int total_length=total.length;
System.out.println();
for (int j=0;j<n;j++)
System.out.println(j+") "+name[j]);
int count[]=new int[total_length];
A: for (int i=0;i<total_length;i++) {
System.out.println();
for (int k=0;k<n;k++) {
if(name[k].equalsIgnoreCase(total[i]))
continue A;
}
System.out.println(total[i]);
System.out.print("Enter:");
int f=sc.nextInt();
count[i]=f;
}
System.out.println();
int c=0;
for(int h=0;h<n;h++) {
for (int v=0;v<total_length;v++) {
if(h==count[v])
c++;
}
System.out.println(name[h]+"="+c);
c=0;
}
}
public static void main(String args[]) {
input_stuff();
}
}
import java.util.*;
class my{
static Scanner sc=new Scanner(System.in);
static void input_stuff() {
System.out.println("Enter the number of candidates");
int no_of_candidate=sc.nextInt();
System.out.println("Enter the name of the candidate");
String name_of_candidate[]=new String[no_of_candidate];
for (int i=0;i<no_of_candidate;i++) {
name_of_candidate[i]=sc.next();
}
vote(name_of_candidate,no_of_candidate);
}
static void vote(String name[],int n) {
String total[]= {"Raghavan","Jagarnath","Manish","Manish K","Shiwam","Nikhil","Navin","Binod","Ankit","Mohit"};
int total_length=total.length;
System.out.println();
for (int j=0;j<n;j++)
System.out.println(j+") "+name[j]);
int count[]=new int[total_length];
A: for (int i=0;i<total_length;i++) {
System.out.println();
for (int k=0;k<n;k++) {
if(name[k].equalsIgnoreCase(total[i]))
continue A;
}
System.out.println(total[i]);
System.out.print("Enter:");
int f=sc.nextInt();
count[i]=f;
}
System.out.println();
int c=0;
for(int h=0;h<n;h++) {
for (int v=0;v<total_length;v++) {
if(h==count[v])
c++;
}
System.out.println(name[h]+"="+c);
c=0;
}
}
public static void main(String args[]) {
input_stuff();
}
}
Comments
Post a Comment