You may not give a copy of your code to your designated pair-programming partner if you did not develop the code together.

You may not show your completed code to another person or look at another person's code until you complete and submit this assignment, except for code you develop together with your pair-programming partner.

You may get help from people other than your pair-programming partner if you get stuck, but only if they do not show or tell you the code to type.

Remember that the instructor performs similarity tests on programming project submissions, and plagiarized code is usually very easy to detect.

Project 1: Loop Worksheet

Counting loops are very commonly used in programming to ... count things. Character data types are used to store and display individual letters and other symbols. The string type stores sequences of characters. In this project we explore the relationships between counting loops, characters and strings in C++.

Project Specifications

Keep the same filename and add to the existing code to complete the project. Leave the existing code unchanged, except as explained with comments and these instructions. Include all your code in this single file.

Add your name and the date to the file comment block at the top of the file.

User input is already coded into the worksheet.

Do not add any other input commands or change the input order.

Complete each of the following steps and code your solutions into the worksheet where indicated by the comments. See the Example Run to verify the correctness of each output.

Use a for-loop to print the number that the user entered (n) and followed by a space for n times.See lesson 5.1.2 for information on for-loops.

Use a for-loop to print a row of "x" on a single line that is n characters long.See lesson 5.2.1 for an example.

Use a for-loop to print the message (msg) followed by a newline n times.See lesson 5.1.2 for information on for-loops.

Use a for-loop to sum the numbers from 1 to n.See lesson 5.1.3 for an example.

Use a for-loop to count the number of times that the character ch occurs in the message.See lesson 6.1.3 for information on iterating strings.

Example Run: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and wording of the output. For the input shown you must get the same output. However, the output must change properly if the inputs are different.

In the above example run, the user entered the values shown in aqua italics (for emphasis) to produce the output. Your program does NOT print the characters in aqua italics, nor does the user input appear in aqua italics.

After displaying the output, exit the program.

Submit the source code file loopwork.cpp with the rest of the assignment as described in Deliverables.

Hints:

To count characters, use a second variable to store the count of characters.

Project 2: Tallying Votes

Elections are a formal group-decision making process by which a population chooses a person to hold office, such as the mayor of a city. Another use of elections is to accept or reject a political proposition. [1]

Most election results are tallied, or counted, using electronic voting. Most electronic voting machines use a computer to take care of the chore of casting and counting votes [2]. In this assignment we will develop a program to count votes.

Project Specifications

Write a C++ program that tallies, or counts, votes. The user enters votes based on a simple menu that presents the candidates. The user then inputs a single character to choose their candidate from the menu. Entering an 'X' (without the quotes) will exit the tallying operation and present a summary of the votes.

Name the source code file vote.cpp and include all your code in this single file.

Be careful of the spelling, including capitalization, as you will lose points for a misspelled name. Naming is important in programming.

Ask the user for a single character as input, and no other input, as shown in the Example Run.

Feel free to choose any candidate names but be sure to report the results by candidate names and neatly aligned as shown in the Example Run.

Example Run: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and wording of the output. For the input shown you must get the same output. However, the output must change properly if the inputs are different.

In the above example run, the user entered the values shown in aqua italics (for emphasis) to produce the output. Your program does NOT print the characters in aqua italics, nor does the user input appear in aqua italics.

After displaying the Election Results, as shown in the Example Run, exit the program. Display the title of Election Results exactly.

Submit the source code file vote.cpp with the rest of the assignment as described in Deliverables.

Hints:

Review lesson 5.3.3 on how to process a sequence of inputs until a sentinel value is encountered. The sentinel value in this program is 'X' (without the quotes).

References and More Information

Project 3: Real or Fake News Detector

Fake, or hoax, news websites deliberately publish made-up stories as news, using social media to drive web traffic and amplify their effect [1]. This is a form of dishonesty known as a scam or swindle, and has been a boon for people trying to make a quick profit. Profit for fake news sites is primarily driven by online advertising revenue made mostly through Facebook and Google [2]. Both Google and Facebook have announced measures to ban web sites that show illegal or misleading content [3][4][5]. Do NOT confuse fake news with opinionated analysis from sites made on the basis of their ideologies.

For this project you are to write a program to help identify fake (made up) news. The instructor is providing you with five (5) "news" samples from the internet for testing your program. Two (2) of the samples are fake news articles and three (3) are real news articles. You must decide which are fake and which are real and write your program to identify them correctly.

Project Specifications

The name of the source code file for this program must be realfake.cpp and all your code must be in this file.

Be careful of the spelling, including capitalization, as you will lose points for a misspelled name. Naming is important in programming.

Your program must run from the command line using redirection of input as follows:

./realfake < input.txt

Where input.txt is the news article file to test.

Your program must print out a single word "Real" or "Fake" (without the quote marks) when run, depending on the article scanned, like this:

./realfake < input.txt
Fake

Your program must correctly output the word "Fake" on two (2) articles and "Real" on three (3) articles based on the contents of the articles.

After printing the appropriate word, exit the program. Do NOT loop and run again.

Submit this project with the rest of the assignment as described in Deliverables.

Hint:

Review lesson 6.1.6: Processing Text Input and choose a way to process text for your approach. Try processing one of the files with both looping techniques and see which one would be easier for you.

After viewing the output of both looping techniques, think of the if-statements you will need to find a unique word or line in each of the files. Ideally, make your detector extensible to similar "news" articles.

Your final program should have a singlewhile-loop and several if-statements inside the loop.

Extra Credit

The following are worth extra credit points:

Complete the assignment using pair programming with the same person for all three projects. (2 points)

After presenting the election results, display the name of the winner. The winner is the candidate with the most votes. Use this wording, substituting the winner's name for <winners name>, and assume no candidate is tied. (2 points)

The winner is <winners name>!

Display the name of the news agency for which you used to determine the fake or real designation. (1 point)

Tutorial Lab

In preparation for next weeks lessons, complete the following:

Read the assigned reading in the textbook

Complete the Tutorial Exercises in CodeLab 6 before the specified due date.

Refer to the assigned reading for the next lesson to help you understand the problems. Also, you can use the online lecture notes for more information as the notes become available. You can look at solutions if you miss your first few attempts and are stuck by clicking the "Solution" tab.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Thus you should check your assignment against these criteria to maximize your score.

Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive. Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

You must submit all the files needed to complete your assignment. Your assignment must work as submitted. Remember to test and double check your files before submitting them. If you make a mistake, you can resubmit up to the deadline. If you resubmit, you must include all your assignment files in the last submission as Canvas hides prior submissions.