0% found this document useful (0 votes)
18 views

Automated Voting Machine System

Uploaded by

AljamesJayme
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Automated Voting Machine System

Uploaded by

AljamesJayme
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

package redefense;

import java.util.Scanner;

public class Redefense {

public static void main(String[] args) {


Scanner ax = new Scanner(System.in);

int select,admin = 1,account = 1,voter = 0 ;


String user,password;
String name[] = new String[100];
int age[] = new int[100];
String address[] = new String[100];
int c1v = 0;
int c2v = 0;
int c3v = 0;
int vp1 = 0;
int vp2 = 0;
int vp3 = 0;
int sec1 = 0;
int sec2 = 0;
int sec3 = 0;

try{
do {
System.out.println("*** Admin Login ***");
System.out.print("Enter User: ");
user = ax.nextLine();
System.out.print("Enter Password: ");
password = ax.nextLine();
if(user.equals("admin") && password.equals("admin")){
do {
System.out.println("*** Main Menu ***");

System.out.println("[1] Add Voters Information");


System.out.println("[2] View Voters");
System.out.println("[3] Update Voters Information");
System.out.println("[4] Delete Voters Information");
System.out.println("[5] Vote");
System.out.println("[6] Officail Tally");
System.out.println("[7] Logout");
System.out.print("SELECT NUMBER[]: ");
select = ax.nextInt();
ax.nextLine();
switch(select) {

case 1 :
//add voters info
System.out.println("*** Add Voter's
Information ***");
System.out.print("Name: ");
name[voter] = ax.nextLine();
System.out.print("Address: ");
address[voter] = ax.nextLine();
System.out.print("Age: ");
age[voter] = ax.nextInt();
if(age[voter]<=17){
System.out.println("You cant Vote!!");
System.out.println("Press Enter to
Continue");
String temp = ax.nextLine();
break;
}

System.out.println("User Successfully
Created!");
System.out.println("Press Enter to
Continue");
String temp = ax.nextLine();
voter++;
break;
case 2 :
//view voters
System.out.println("*** View Voters ***");
if(voter != 0) {
System.out.println("");
for(int x=0;x<voter;x++) {
if(!name[x].equals("null")) {

System.out.println("Name\t\tAge\t\tAddress ");

System.out.println(name[x]+"\t\t"+age[x]+"\t\t"+address[x]);
}
}
System.out.print("Press Enter to
Continue");
String enter2 = ax.nextLine();
}else {
System.out.println("No Record!");
System.out.print("Press Enter to
Continue");
String enter3 = ax.nextLine();
}
break;
case 3 :
//Update
System.out.println("*** Update User ***");
if(voter != 0) {
int updateCounter = 0;
System.out.print("Enter the name: ");
String delName = ax.nextLine();
for(int y=0;y<voter;y++) {
if(delName.equals(name[y])){
System.out.println("Current
Information");

System.out.println("Name\t\tAge\t\tAddress ");

System.out.println(name[y]+"\t\t"+age[y]+"\t\t"+address[y]);
System.out.print("Enter New
Name: ");
name[y] = ax.nextLine();
System.out.print("Enter New
Address: ");
address[y] = ax.nextLine();
System.out.print("Enter New
Age: ");
age[y] = ax.nextInt();

System.out.println("Voter
Successfully Updated!");
System.out.println("Press
Enter to Continue");
String temp1 = ax.nextLine();
updateCounter++;
}
}
if(updateCounter == 0) {
System.out.println("No Match
Found!");
System.out.println("Press Enter to
Continue");
String temp1 = ax.nextLine();
}
}else {
System.out.println("No Record!");
System.out.print("Press Enter to
Continue");
String temp1 = ax.nextLine();
}
break;
case 4 :
//delete voters info
System.out.println("*** Delete Voter's
Information ***");
if(voter != 0) {
System.out.println("Name");
for(int x=0;x<voter;x++) {
if(!name[x].equals("null")) {
System.out.println(name[x]);
}
}
System.out.print("Enter the name: ");
String delName = ax.nextLine();
int delAccount = 0;
for(int y=0;y<voter;y++) {
if(delName.equals(name[y])){
name[y] = "null";
System.out.println(delName +
" Successfully Deleted!");
System.out.print("Press Enter
to Continue");
String enter4 =
ax.nextLine();
delAccount++;
}
}
if(delAccount == 0) {
System.out.println("No Match
Found!");
System.out.print("Press Enter to
Continue");
String enter5 = ax.nextLine();
}
}else {
System.out.println("No Record!");
System.out.print("Press Enter to
Continue");
String enter6 = ax.nextLine();
}
break;
case 5 :
//Voting
System.out.println("*** Proceed To Voting
***");
if(voter != 0) {

System.out.print("Voters name: ");


String Name = ax.nextLine();
for(int y=0;y<voter;y++) {
if(!
name[y].equals("null")) {
if(age[y]>=18){

System.out.println("Candidate's For President:\t\tDuterte\t\tNoynoy\t\tBinay");

System.out.print("Vote for: ");


String voting =
ax.nextLine();

System.out.println("Candidate's For Vice


President:\t\tDuterte\t\tNoynoy\t\tBinay");

System.out.print("Vote for: ");


String voting2 =
ax.nextLine();

System.out.println("Candidate's For Secretary:\t\tDuterte\t\tNoynoy\t\tBinay");

System.out.print("Vote for: ");


String voting3 =
ax.nextLine();

if((voting.equals("duterte"))||(voting.equals("Duterte"))||
(voting.equals("DUTERTE"))){
c1v++;
break;
}
if
((voting.equals("noynoy"))||(voting.equals("Noynoy"))||(voting.equals("NOYNOY"))) {
c2v++;
break;
}
if
(voting.equals(("binay"))||(voting.equals("Binay"))||(voting.equals("BINAY"))) {
c3v++;
break;
}

//vp
if((voting2.equals("duterte"))||(voting2.equals("Duterte"))||
(voting2.equals("DUTERTE"))){
vp1++;
break;
}
if
((voting2.equals("noynoy"))||(voting2.equals("Noynoy"))||
(voting2.equals("NOYNOY"))) {
vp2++;
break;
}
if
(voting2.equals(("binay"))||(voting2.equals("Binay"))||(voting2.equals("BINAY"))) {
vp3++;
break;
}

if((voting3.equals("duterte"))||(voting3.equals("Duterte"))||
(voting3.equals("DUTERTE"))){
sec1++;
break;
}
if
((voting3.equals("noynoy"))||(voting3.equals("Noynoy"))||
(voting3.equals("NOYNOY"))) {
sec2++;
break;
}
if
(voting3.equals(("binay"))||(voting3.equals("Binay"))||(voting3.equals("BINAY"))) {
sec3++;
break;
}

}else{

if(age[y]<=17){

System.out.println("Ages Below 18 Can't Vote!");


--c1v;
--vp1;
--sec1;

System.out.print("Press Enter to Continue");


String enter7 =
ax.nextLine();
break;
}
if(age[y]<=17){

System.out.println("Ages Below 18 Can't Vote!");


--c2v;
--vp2;
--sec2;
System.out.print("Press Enter to Continue");
String enter7 =
ax.nextLine();
break;
}
if(age[y]<=17){

System.out.println("Ages Below 18 Can't Vote!");


--c3v;
--vp3;
--sec3;

System.out.print("Press Enter to Continue");


String enter7 =
ax.nextLine();
break;
}

}
}

}//pres
if
(voter<c1v) {

System.out.println("You can't vote twice!");


--c1v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}
if (voter<c2v)
{

System.out.println("You cant vote twice!");


--c2v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}
if (voter<c3v)
{

System.out.println("You cant vote twice!");


--c3v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}

if (voter<vp1) {
System.out.println("You can't vote twice!");
--c1v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}
if (voter<vp2)
{

System.out.println("You cant vote twice!");


--c2v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}
if (voter<vp3)
{

System.out.println("You cant vote twice!");


--c3v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}

if (voter<sec1)
{

System.out.println("You can't vote twice!");


--c1v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}
if (voter<sec2)
{

System.out.println("You cant vote twice!");


--c2v;

System.out.println("Press Enter to Continue");


String
enter7 = ax.nextLine();
break;
}
if (voter<sec3)
{

System.out.println("You cant vote twice!");


--c3v;
System.out.println("Press Enter to Continue");
String
enter7 = ax.nextLine();
break;
}

}else{
System.out.println("No Records
Found!");
}

break;
case 6 :
System.out.println("*** OFFICIAL TALLY
***");

System.out.println("Candidate:\t\tDuterte\t\tNoyNoy\t\tBinay");
System.out.println("Vote
Counts:\t\t"+c1v+"\t\t"+c2v+"\t\t"+c3v);

System.out.println("Candidate:\t\tDuterte\t\tNoyNoy\t\tBinay");
System.out.println("Vote
Counts:\t\t"+vp1+"\t\t"+vp2+"\t\t"+vp3);

System.out.println("Candidate:\t\tDuterte\t\tNoyNoy\t\tBinay");
System.out.println("Vote
Counts:\t\t"+sec1+"\t\t"+sec2+"\t\t"+sec3);

System.out.print("Press Enter to
Continue");
String enter7 = ax.nextLine();
break;

case 7 :
account = 0 ;
System.out.println("Successfully Logout!");
break;
default :
System.out.println("Invalid Choice");
System.out.print("Press Enter to Continue");
String enter8 = ax.nextLine();
}
} while(account == 1);
}else{
System.out.println("Invalid user or password!");
}
} while(admin == 1);

}catch(Exception e){
System.out.print(e);
}
}

You might also like