Question
Can someone guide me on what to do and code this? I like learning from already coded code so i can teach my self, plus
Can someone guide me on what to do and code this? I like learning from already coded code so i can teach my self, plus i have to do it at some point, i am lost please help .
The assignment contains two parts.
Scientific calculator. Study tracking changes and automatic indentation in MSVS described here. As you program your project below, demonstrate to the lab instructor applying automatic indentation to your code.
Study these functions of the math library. Create a project titled Lab4_Calculator with a single file titled calculator.cpp. Write a program that:
prints a numbered menu of mathematical operations as shown below;
then prompts the user to select an operation;
then prompts and inputs the operands for the selected option (note that some operations require one and some two operands);
then computes and outputs the result.
The process repeats. The program should quit if the user inputs an option (number) that is not listed. The dialog should look as follows:
1. absolute value 2. square root 3. floor 4. power Select an operation: 4 Enter base: 2 Enter exponent: 3 The result is: 8 Select an operation: ...
Guessing game. Create a project titled Lab4_Guess with a single file titled guess.cpp Program the following game. The computer selects a random number between 1 and 50 and asks the user to guess the number. If the user guesses incorrectly, the computer states whether the selected number is smaller or greater than the guess. The guessing repeats until the user guesses the number. The dialog should look as follows:
I selected a number between 1 and 50, what is it? 20 wrong, it is larger, what is it? 40 wrong, it is smaller, what is it? 30 wrong, it is larger, what is it? 35 wrong, it is smaller, what is it? 34 correct!
For your program you need to use predefined randomization functions rand() and srand() as well as the time function time()
Function time() returns current time (as kept by the computer) in the number of seconds passed since midnight, January 1, 1970. You need to include ctime to use this function. The function takes one argument but for this assignment the argument value is a special named constant nullptr. Check this program for an example usage.
To use functions rand() and srand() you need to include cstdlib Function srand() initializes the random number generator of the program. It takes a single integer argument. The value passed to srand() determines the values output by rand(). This value is called seed.
rand() takes no arguments. Every time rand() is invoked it returns an integer value between 0 and constant RAND_MAX defined in cstdlib. Note that the sequence of values returned by repeated calls of rand() is uniquely determined by the seed passed to srand(). That is, if srand() is passed the same seed, rand() is going to return the same sequence of numbers. This is helpful for debugging. Check this program for an example of random number manipulation.
Hints: Use fixed values of the seed for your initial debugging, use the output of time() as an unpredictable seed to start the guessing game once you debugged your program.
Note that random value produced by rand() is out of the required range of 1-50. To get the random number into the required range, remainder it by 50 (that puts the number in 0-49 range) and then add one.
Do not put srand() inside the loop or anywhere, where it may be invoked more than once - it resets the random number generator.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started