Expert Answer:C++ project: Program to play Hangman

  

Solved by verified expert:This is a c++ project that requires detail comments on code. Please read the instructions carefully and finish it as simple as possible. (this is not a major course for me)
project_3___fun_with_formulas.docx

Unformatted Attachment Preview

Don't use plagiarized sources. Get Your Custom Essay on
Expert Answer:C++ project: Program to play Hangman
Just from $10/Page
Order Essay

Project 3: Fun with Formulas!
Overview: Your project is to create a set of functions that solve famous math functions. The main program should
present a menu to the user to allow them to choose which function to run. The results should then be displayed to the
user. In addition, you will need to test a variety of conditions for each function.
Goal: The goal of the project is to create and call your own functions and to practice test case development.
Description: The user will be able to select which function to run. Depending in the selection, prompt the user for
the appropriate input value(s). Then display the result.
Your menu may look something like this:
1) Convert Celsius to Fahrenheit
2) Convert Fahrenheit to Celsius
3) Compute the Greatest Common Denominator of Two Numbers
4) Solve the Pythagorean Theorem
5) Compute the Fibonacci of a number
6) Calculate the square root of X
7) Calculate the power of x to y.
8) Test for Narcissistic Number
9) Run Test Cases
10)
Exit
Test Case Development: Your code should contain a function whose purpose is to test the code in your program.
Option (7) above should call a “driver” function whose purpose is to validate the other functions. You should make sure
to comment exactly what the driver function is testing. Remember that you want to be sure to test:



Common Cases
Boundary Cases
Error Cases
Your test cases will be graded on how thoroughly they test your regular code.
Formula Descriptions
The following is a description of how each formula works:
FtoC:
Perform a Fahrenheit to Celsius conversion: degC = (5 / 9) * (degF – 32). degF > -459.67
CtoF:
Perform a Celsius to Fahrenheit conversion: degF = (1.8)*degC + 32. degC > -273.15
Euclid’s Algorithm:
There is a well-known algorithm called “Euclid’s Algorithm” for computing the Greatest Common Denominator of
two positive integers. If either argument is less than or equal to zero, the value zero will be returned as a flag to
indicate an error. If both arguments are strictly positive, then their g.c.d. will be returned. Thus, for example, if
parameter (a) has the value 28 and (b) has the value 70, then the function will return the value 14.
General approach: The first integer is divided by the second, and then the second is divided by the remainder, and
then the first remainder is divided by the second, and so on until a remainder of 0 is obtained. The g.c.d. will be the
divisor that produced 0 remainder.
Pythagorean Theorom:
This is the classic triangle side equality: a2 + b2 = c2. To implement this function, pass in values for a, b, and c.
Solve the equation for the missing value. The missing value will be represented by a 0. So




Pyth(3,4,0) = 5
Pyth(3, 0, 5) = 4
Pyth(-1, 4, 5) is an error condition.
Pyth(0, 0, 5) is an error condition
So your code needs to test for exactly one zero. Solve the equation for the parameter that is zero. Negative
input parameters also result in an error condition.
Square Root Estimation:
Suppose that you want to find square root of the number 49. The square root lies between 0 to 49. Let’s
iteratively calculate the square root. Set a variable to be the lower bound as 0 and another as upper bound of
49. Now take the exact middle value and check whether the square of that middle value is anywhere near to the
number.
temp = (lower_bound + upper_bound)/2
This results in temp = 24.5. Square this number. If the square is equal to the original number, then we have
found the square root. In this example, temp * temp = 600.25. This result is large than the number, so we now
know that the square root lies between 0 and 24.5. Repeat with the upper bound as 24.5. Continue this
procedure till we find the exact square root of the given number. If the result is smaller than the number, then
set the lower bound equal to temp and the upper bound remains at number.
Fibonacci :
Compute the Fibonacci result based upon an input number. The input must be non-negative. This famous sequence
looks like this:
The basic formula is this:
The function should return the value (not the sum). For example, fib(10) = 55.
Power xy
Repeatedly multiply X by itself Y times. Return the result. Y can be negative resulting in a fractional amount.
Narcissistic Number:
Determine if a number is the sum of their own digits to the power of the number of digits. Returns true or false. For
example, 407 = 43 + 03 + 73. You can assume a maximum of 4 digits.
Extra Credit +2 Points – Relax the restriction on the number of digits. In this case, you can use an array to story
intermediate values.
Extra Credit +(1-4) Points – Add other functions to the menu option. For example, Prime Numbers – given an input
return whether the number is prime or not. The more complex the function, the more points will be given.
Hint: When developing your project, you will want to use incremental development, which is to say, you’ll want to write
the simplest stand-alone function first, e.g. ftoc(). You’ll then want to add the code to test your ftoc() code. Once you’re
confident ftoc() works, you can move on to the next function.
Coding Requirements: Your program should perform user input validation on the menu. The user should be
allowed to enter illegal values. If an illegal value is entered, your function should catch this error and display a message.
Then return back to the main menu. Your code should be thoroughly commented, and you should follow all of the good
programming practices we have discussed in class, e.g. commenting, meaningful variable names, indentation, etc. You
are not allowed to use GLOBAL VARIABLES, goto statements.
You must follow all of the good programming practices discussed in class:
• Comment your code thoroughly.
• Indent your code appropriately.
• Use meaningful variable names.
• No use of global variables.
• Provide the user with understandable prompts and instructions.
• Make sure your name is included in comments at the top of your code.
• You are NOT allowed to use goto statements in this or any other COMP 51 projects.
• …
If this is not done, points will be deducted from your program and it will be impossible to earn an ‘A’.
If you want to add a math formula not mentioned in the list above, you can do so for 3 extra credit points. You will need
to provide clear comments that the new function is for extra credit.
Submission:
Using the Canvas assignment feature, you should submit the source code (.cpp file). Make
sure you submit your assignment after uploading the file attachment!

Our essay writing service fulfills every request with the highest level of urgency.
attachment

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 30% with the discount code ESSAYSHELP