Question

Purpose: To familiarize yourself with variables and arithmetic. Directions: Convert the following problems below to c++...

Purpose: To familiarize yourself with variables and arithmetic.


Directions: Convert the following problems below to c++ equivalent code. Each problem should be done within the same file and all within the same main function. After each step is performed the user should be shown the updated value that was changed. Turn in the finished c++ (.cpp) file for problem 0-6 and the image file for problem 7. Remember to reset or use unique variables for each problem (you cannot declare a variable by the same name twice). In each problem, the user will enter a number(s) on the first step only.

Problem 1-:

Part 1
Take any 2 digit number from 31 to 99. (You do not have to check the numbers just assume the user will enter a valid number so long as you tell them to).
Store an extra copy of this number for later
3. Add 82 to the number.
4.    Remove the hundreds place from your number (by modulus operation)
5. Add 1 to the number.
6.   Subtract this from your original number (stored in step 2).
7.    Output the result obtained

Part 2

Take a random number from the user
Multiply the number by 4
Add 1 to the number
Multiply by the original number that the user input
Subtract the original number away
Take the square root of the number (you can use cmath’s sqrt function)
Divide the number by 2
The result should be the original number

Part 3

Get a random number from the user
Remember the original number
Add 3 to the number
Double the number
and then multiply by 5.
Knock off the last digit (remove the 1’s place)
Finally remove the original number
What is the result?

Problem 2-:

Part 1

1: Have the person write down any three digits number with decreasing digits (432 or 875).
2: Reverse the number you wrote in #1.
3: Subtract the number obtained in #2 from the number you wrote in #1 (#1 - #2)
4: Reverse the number obtained in #3
5: Add the numbers found in #3 and #4
What is the answer?

Part 2

For this problem I want you to draw out a flow chart to illustrate the logic. You may use word, DIA, or any other software you choose but be specific on the symbols used to illustrate this problem. If you use hand drawn, make sure the paper is unlined and that your picture of it is clear and legible. Please submit this problem as an image file
Take any random 2 digit number
Divide the number by 2

Add 17 to the number
If the first digit (10’s place) of the number is greater than the last than add the first digit to the number, otherwise add the second digit (1’s place)
If the number is greater than 21 subtract the product of the 2 digits.
Repeat this until the number is less than 21
Output the results of the number

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question. Please post only 1 question at a time. Due to time limit we cannot address all the questions. Also , per Chegg policy, we are limited to answer only the first question and its sub parts.

For the set of questions, I have solved Question 1 and all the 3 parts.

Please post question 2 in a sepearate post and I will be able to assist you in that as well.

thanks for understanding.

Here are the code for the 3 parts.

====================================================================

// Problem 1 : Part 1

# include <iostream>

using namespace std;

int main(){

               

                int num; int copyNum;

               

                cout<<"Please enter a 2 digit number: "; cin >> num;

                copyNum = num ;

               

                num += 82 ; // add 82

                num %= 100; // remove the hundreds place from the number

                num += 1; // add 1

               

                int result = copyNum - num;

               

                cout<< "Result : " << result << endl;

               

}

====================================================================

// Problem 1 : Part 2

# include <iostream>

# include <cmath>

using namespace std;

int main(){

               

                int randomNum; int copy;

               

                cout << "Enter a random number : " ; cin >> randomNum ;

               

                copy = randomNum;

               

                randomNum = randomNum * 4;

                randomNum = randomNum + 1;

               

                randomNum = randomNum * copy ;

               

                randomNum = randomNum - copy ;

               

               

                double sqRoot = sqrt ( randomNum );

               

                sqRoot = sqRoot / 2;

               

                cout <<"Result : " << sqRoot << endl ;

               

}

====================================================================

// Problem 1 : Part 3

# include <iostream>

# include <cmath>

using namespace std;

int main(){

               

                int randomNum; int copy;

               

                cout << "Enter a random number : " ; cin >> randomNum ;

               

                copy = randomNum;

               

                randomNum = randomNum + 3;

               

                randomNum = randomNum + randomNum;

               

                randomNum = randomNum * 5;

               

                randomNum = randomNum/10; // knock off the first place

               

                randomNum = randomNum - copy ;

               

                cout <<"Result : " << randomNum << endl;

}

====================================================================

Add a comment
Know the answer?
Add Answer to:
Purpose: To familiarize yourself with variables and arithmetic. Directions: Convert the following problems below to c++...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • DIRECTIONS FOR THE WHOLE PROJECT BELOW BigInt class The purpose of the BigInt class is to...

    DIRECTIONS FOR THE WHOLE PROJECT BELOW BigInt class The purpose of the BigInt class is to solve the problem using short methods that work together to solve the operations of add, subtract multiply and divide.   A constructor can call a method called setSignAndRemoveItIfItIsThere(). It receives the string that was sent to the constructor and sets a boolean variable positive to true or false and then returns a string without the sign that can then be processed by the constructor to...

  • Open the Validate Number Solution.sln file contained in the VB2017\Chap07\Validate Number Solution folder. The interface provides...

    Open the Validate Number Solution.sln file contained in the VB2017\Chap07\Validate Number Solution folder. The interface provides a text box for entering a 9-digit number. The btnValidate_Click procedure should use the algorithm and example shown in Figure 7-56 to validate the user’s entry. The procedure should display a message indicating whether the entry is or is not valid. Code the procedure. Include any other code that will professionalize the interface. Save the solution and then start and test the application. Create...

  • Write a calculator that will give the user this menu options: 1)Add 2)Subtract 3)Multiply 4)Divide 5)Exit...

    Write a calculator that will give the user this menu options: 1)Add 2)Subtract 3)Multiply 4)Divide 5)Exit . Your program should continue asking until the user chooses 5. If user chooses to exit give a goodbye message. After the user selections options 1 - 4, prompt the user for two numbers. Perform the requested mathematical operation on those two numbers. Round the result to 1 decimal place. Please answer in python and make it simple. Please implement proper indentation, not just...

  • I need to create a bit of code for javascript which I can have random numbers...

    I need to create a bit of code for javascript which I can have random numbers generate with a certain amount of digits set by the user. and ask the user how many times they want this to happen. For example The user says they want a number with 4 digits (any number between 0 - 9999) and the user can input if they want to add, subtract, multiply, divide, or make it random 2 random numbers are generated. First...

  • Write MIPS code that emulates a simple calculator. The calculator initially has the value 0. Prom...

    Write MIPS code that emulates a simple calculator. The calculator initially has the value 0. Prompt the user to enter a command. A command is a number, where 0 is add, 1 is subtract, 2 is multiply, 3 is divide, 4 is clear, and 5 is exit. When the user enters 0, 1, 2, or 3, prompt the user for a number to add, subtract, multiply or divide from the current value. If the user enters 4, then clear the...

  • Do not use pointer variables, pointer arithmetic or operater new ITCS-2530    Project                        Write an...

    Do not use pointer variables, pointer arithmetic or operater new ITCS-2530    Project                        Write an interactive program that performs fractional calculations. You need define a class CFrac for a fractional number according to the UML diagram below: CFrac - numerator : int - denominator : int - simplify () : void + CFrac (int = 0, int = 1) + ~CFrac() + add (const CFrac&) const : CFrac + subtract (const CFrac&) const : CFrac + multiply (const CFrac&)...

  • Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the...

    Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the opposite of what you have done in Assignment 4). Make sure that you create a new Project and Java class file for this assignment. Your file should be named “Main.java”. You can read about octal-to-decimal number conversions on wikepedia Assignment 4 is at the bottom Objective Your program should prompt the user to enter a number of no greater than 8 digits. If the...

  • Multiples of 9’s (JAVA) Using the logic behind the algorithm in Part 1, it’s easy to...

    Multiples of 9’s (JAVA) Using the logic behind the algorithm in Part 1, it’s easy to calculate the first nine multiples of 9 (9x1, 9x2, 9x3…, 9x9). Let’s use two examples. First, to determine the product of 9 times 6, perform the following algorithm: Step 1: Subtract 1 from the number being multiplied by 9 (in this case 6) to get the first digit of the product: 6 – 1 =  5. Step 2: Subtract that digit from 9 to get...

  • Part 1 – Data Encryption Data Encryption is the process of transforming data, using a cipher,...

    Part 1 – Data Encryption Data Encryption is the process of transforming data, using a cipher, to make it unreadable to anyone except those possessing special knowledge. In this problem you will implement a simple encryption technique on data that comprises of non-negative integers that have at least six digits with no leading zeroes. In order to encrypt the number the following functions are to be implemented: void input(int *num); int add4(int num); int shift(int num); void printOutput(int encryptNum, int...

  • 3. (Dynamic Array) In C++, the largest int value is 2147483647. So. an integer larger than this cannot be stored and pr...

    3. (Dynamic Array) In C++, the largest int value is 2147483647. So. an integer larger than this cannot be stored and processed as an integer. Similarly, if the sum or product of two positive integers is greater than 2147483647, the result will be incorrect. One way to store and manipulate large integers is to store each individual digit of the number in an array. Your program must, at least, contain a function to read and store a number into an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT