Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C# Your company has been hired to develop a new voting system for the upcomin

ID: 3831247 • Letter: I

Question

In C# Your company has been hired to develop a new voting system for the upcoming Presidential Elections. Your boss comes to you and ask you to be the head developer to complete this task. He explained the main problems of the current system and at the same time gives you the requirements for the new system which are as follows: 1) System Configuration: a. System must be capable to configure which parties are involved in the presidential elections (ex: Democratic, Republican, Independent, etc.) b. System must be capable to configure the president candidate's names (ex: Hillary Clinton, Donald Trump, etc.) c. System must be capable to configure the vice president candidate's names (ex: Bernie Sanders, Ted Cruz, etc.) d. System must be capable to run endlessly unless a sentinel character is entered. 2) System Output Display (Each ballot must contain the following information) a. A welcome greeting message must be displayed explaining the voter how to use the new voting system. b. Display candidates and Party information i. Candidate's name and Party (President) ii. Candidate's name and Party (Vice President) 3) Voting Begins: a. System must prompt voters to enter voter's name and identification. b. System must be capable to record each vote for president and vice president. c. After each ballot a message must prompt the voter if vote has been successful or not 4) Results a. Results must be displayed ONLY when the system has been successfully completed, in other words when the sentinel character has been entered. b. Output must display the winner President and Vice President with the number of votes that each candidate received. c. Output must also display which candidate was second, third, and so on (president and vice president) with total number of votes that each candidate received as well.

Explanation / Answer

The new voting system for the President rule is being developed in c# along with asp.net and database.

The first thing you need to set-up an database with VotersApplication and start embedding the columns into it. Here, I have created the code for both Implementation and Testing.

So let me brief you about the Implementation program along with the comments into it.

One Class for Implementation:

Program:-

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public class Voter

{

// Created a method named EligibleVoter

private void EligibleVoter(string vID)
{
// This is to connect your database to the c# code
  
SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
  
   // I have created the table name Votes and column_name as CountVotes along with the vID as primary key
  
SqlCommand cmd = new SqlCommand("UPDATE Votes SET CountVotes = CountVotes+1 WHERE vID=@vID", conn);
cmd.CommandType = CommandType.Text;

cmd.Parameters.AddWithValue("@vID", vID);

using (conn)
{
//Now, it will open and connect to the database
conn.Open();
  
       // This statement is used to execute the update query which we have written at top
      
cmd.ExecuteNonQuery();
}

protected void btn_Click(object sender, EventArgs e)
{
  
EligibleVoter("A");
}

}

One Class for Testing:

Program:-

<!doctype html>
<html>
<head>
<title> Voting System </title>
</head>

<body>
<form id="votingForm" runat="server">
<div>
<asp:voterLoginView ID="voterLogView" runat="server">
<AnonymousTemplate>
<asp:voterLogin ID="voterLogView2" runat="server">
</asp:voterLogin>
</AnonymousTemplate>
</asp:voterLoginView>
<br />
<table>
<tr>
<td>
<asp:Label ID="labelA" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:Label ID="labelB" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="VoteAbtn" runat="server" Text="Type Vote A" />
</td>
<td>
<asp:Button ID="VoteBbtn" runat="server" Text="Type Vote A" />
</td>
</tr>
</table>

</div>
</form>
</body>

</html>