[Solved] CPP Assignment 2

30 $

File Name: CPP_Assignment_2.zip
File Size: 150.72 KB

SKU: [Solved] CPP Assignment 2 Category: Tag:

Or Upload Your Assignment Here:


In general always write your name and date of creation as comments in the files andtry to be “user friendly” when you write the code:● Add comments on the code to remember yourself and the other whatthe code does● Manage the possible errors in the input given by the userThe 70% of this assignment consists in completing part 1) (including b) and 2) (a andb), but if the mastermind program is not working 100% is ok!1) Create a program to calculate the power of a number without using the function powor a loop. The base and exponent should be asked to the user and should be integer.a) After that extend the program adding an additional function that takes thesame number of arguments (can have different type) of the previous one andhave the same name but calculate the n-square of the base, where n is theexponent. (Here the function pow could be useful:http://www.cplusplus.com/reference/cmath/pow/ )b) What should be learn: overloading, functions2) Have you ever played the game mastermind? Player A selects 4 balls of variouscolors among 6 choices (RED(R), BLUE(B), GREEN(G), YELLOW(Y), PURPLE(P)and ORANGE(O)), balls can not be repeated . Player B tries to guess what player Achoose by typing combinations of 4 colors. To every attempt players A replies with ablack ball for each color and position guessed correctly and with a white ball for everycolor (and not position) correctly guessed by B. The game ends when player B guessthe position and colors of the 4 balls.a) Try to code this, where player A is the computer and the combination isselected random (remember that you can’t repeat the same ball more thanonce, you need to re-extract if you get a ball already extracted). The usershould be able to play mastermind with the computer that at every turn shouldreply with B or W or nothing depending on the combination of colors (letter)given by the userb) Output all the combinations needed by the user to guess the 4 balls in anoutput file together with a message containing the number of combinations.c) Try to write the code as composed by several functions that are calledin main.d) What to learn: how to output to file, arrays, how to generate random number,extensive use of functions, strings, pointers

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CPP Assignment 2
30 $