Question #34697

Create a program that uses at least two functions that will be called from your main. This program is a number game program that asks for parts of your phone and after manipulating it mathematically, eventually outputs your entire phone number. the directions for this program are
1 enter the firs three numbers of your phone 9not area code)
2 multiply by 80
3add 1 to the total
4 multiply by 250
5 add the last 4 digitts of your phene number (user inputs)
6 add the last 4 digits of your phone number again
7 substract 250 from total
8 divide the number by 2
9 show thw results
1

Expert's answer

2013-09-25T14:28:32-0400
#include <iostream>
#include <cstring>
using namespace std;
/* Asks the user to enter digits of the phone number showing the prompt message */
int get_digits(const string& prompt)
{
    int result;
    cout << prompt;
    cin >> result;
    return result;
}
/* Performs the needed calculations based on the two given numbers */
long perform_calculations(int firstThree, int lastFour)
{
    long result = (firstThree * 80 + 1) * 250 + lastFour * 2 - 250;
    return result / 2;
}
int main()
{
    int firstThree = get_digits("Enter the first 3 digits of your phone: ");
    int lastFour = get_digits("Enter the last 4 digits of your phone number: ");
    cout << "The result is: " << perform_calculations(firstThree, lastFour);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS