Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that determines the results of an election by selecting the person with the largest number of votes as the winner. You have

image text in transcribed

Write a program that determines the results of an election by selecting the person with the largest number of votes as the winner. You have been provided with a text file called "Election_Results.txt", which provides results for 5 candidates. It lists the name of each candidate followed by the '\t' (tab char) and the number of votes the candidate received. Your program should read the information from the file. Use one array to store the candidates name and another to store the number of votes he/she received. To read strings with spaces you will need to use the getline function. Example: getline(filename, string variable, delimiter char); Your program should then determine the winner, and output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate and use manipulators from to print these in a table format on the console as shown below. Your program should also output the winner of the election. See sample output below: Unlike the USA postal zip codes, Canada's postal codes are alphanumeric. The Canadian postal code uses a six-character string and are in the format A1A 1A1, where A is a letter and 1 is a digit, with a space separating the third and fourth characters. Write a program that reads a list of Canadian Postal Codes from the file "PostalCodes.txt", and then verifies whether the postal code is valid or not. Your program should use manipulators from to output the results to the console in a table format as shown in the sample output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions