Java
Java
Reg/No: 22/08501
Assignment 2
Java Programming
Question 1
A)
Here the program prompts the user to enter his age to see if he is eligible for voting.
B)
Here the programs prompts the user select the type of voting he/she wants:
1. In-person voting.
2. Mail-in voting.
3. Online voting.
C)
Here , the program displays the selection that the user has chosen
For instance I selected : ‘’Online Voting’’.
D)
Here, the program prompts the user to select his/her preferred candidate.
I’ve picked “Candidate 2”
E)
Here , the program calculates and displays the percentage of votes each candidate
received based on a randomly generated number of votes per candidate.
The Java Source Code
“/*
*/package votingsystemproject;
import java.util.Scanner;
import java.util.Random;
/**
* @author nimcx
*/
switch (choice) {
case 1:
break;
case 2:
break;
case 3:
break;
default:
} else {
scanner.close();
return;
int i = 1;
if (i % 2 == 0) {
i++;
}
int candidate;
do {
candidate = scanner.nextInt();
int totalVotes = 0;
totalVotes += votes[j];
scanner.close();
}”