Enable contrast version

# Tutor profile: Kathleen F.

Inactive
Kathleen F.
Experienced programming tutor, undergraduate student
Tutor Satisfaction Guarantee

## Questions

### Subject:Calculus

TutorMe
Question:

Find the sum of the following geometric series: $$\sum_{n=1}^{\infty} 2^{-n}$$

Inactive
Kathleen F.
Answer:

To sum a geometric series, we use the formula $$S = a / (1 - r)$$, where $$a$$ is the first term of the series and $$r$$ is the ratio of the first two terms. If the sum converges to a value, the absolute value of $$r$$ will be less than 1: $$| r | < 1$$, else, the sum diverges. To find $$r$$: $$r = a_2 / a_1$$ $$r$$ is equal to the ratio of the first two terms of the series. The second term of the series $$a_2$$ is the term when n = 2 and the first term is when n = 1. When n = 2: $$2^(-2) = 1 / 2^2 = 1/4$$ When n = 1: $$2^(-1) = 1 / 2^1 = 1/2$$ $$r = a_2 / a_1$$ $$r = (1/4) / (1/2)$$ Substitute values for $$a_2$$ and $$a_1$$. $$r = 1/4 * 2/1$$ To divide two fractions, use keep-change-flip (multiply by reciprocal). $$r = 2/4$$ Multiply both fractions. $$r = 1/2$$ Simplify. We check that $$| r | < 1$$: $$| 1/2 | < 1$$ is true. Now, we can use the summation formula $$S = a / (1 - r)$$: $$S = a / (1 - r)$$ $$S = (1/2) / (1 - 1/2)$$ Substitute $$a_1$$ for $$a$$ and $$r$$. $$S = (1/2) / (1/2)$$ Simplify the denominator. $$S = (1/2) * (2/1)$$ Multiply by the reciprocal. $$S = 2/2$$ Multiply both fractions. $$S = 1$$ Simplify. Therefore, $$\sum_{n=1}^{\infty} 2^{-n} = 1$$

### Subject:C++ Programming

TutorMe
Question:

Suppose you have a certain amount of money is a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula, which is known as the future value formula, is: F = P x (1 + i)^t The terms in the formula are as follows: a. F is the future value of the account after the specified time period b. P is the present value of the account c. i is the monthly interest rate d. t is the number of months Write a program that prompts the user to enter the account’s present value, monthly interest rate, and the number of months that the money will be left in the account. The program should pass these values to a function named futureValue that returns the future value of the account, after the specified number of months. The program should display the account’s future value. Check for input validation (no negative values).

Inactive
Kathleen F.
Answer:

First, the standard program setup: #include <iostream> using namespace std; int main() { //main code here } We are asked to create a function named futureValue that takes the account’s present value (a floating point value), monthly interest rate (another float), and the number of months (an integer). We are told that futureValue should return the future value of the account (a floating point value) So, futureValue should be a value-returning function (not void) that returns a float: float futureValue(); Now, we need to change it so that it accepts data for the account's present value, interest, and months: float futureValue(float, float, int); //order is important Now, our updated code: #include <iostream> using namespace std; float futureValue(float, float, int); int main() { //main code here } Now, the futureValue function should implement the futureValue formula (F = P x (1 + i)^t) given P (present value), i (interest), and t (months). Because we used a function prototype, we can start creating the function after the main function, rather than having the program look messy by having functions at the top. To create our function, we type the return type, function name, and the named parameters in parentheses. Unlike the function prototype, instead of just float, float, int, we will give them names, similar to creating variables. #include <iostream> using namespace std; float futureValue(float, float, int); int main() { //main code here return 0; } float futureValue(float presentValue, float interestRate, int numMonths) { //futureValue code here } These names are a little long, though, so we can shorten them to match the variables in our formula: float futureValue(float P, float i, int t) { //futureValue code here } In this function, now we just implement the formula. Let's create a variable that will hold the final value, which should be a float since we are dealing with decimal math. float futureValue(float P, float i, int t) { float fValue = 0; //future value of account } Since this is our "result" variable, let's assign the resulting value of the equation to this variable. We must convert the mathematical expression into something C++ understands, so we can't simply type P * ( 1 + i )^t, because it doesn't know "^" means raising to a power. In some versions of C++, this will require inclusion of a new header file: #include <cmath> And we will use the power function "pow()" which takes two arguments: the base and the exponent. In our formula, the base would be "1 + i" and the exponent is "t". Therefore, this function would be used like so: pow(1 + i, t); Now, we can implement the formula: float futureValue(float P, float i, int t) { float fValue = 0; //future value of account fValue = P * pow(1 + i, t); //implement formula } All that's left to do in futureValue now is to return the resulting value, which means we need to use a return statement (because we designated our function is value returning through the keyword 'float' in the function header). We want to return the variable that did the equation for us, so let's return fValue: float futureValue(float P, float i, int t) { float fValue = 0; //future value of account fValue = P * pow(1 + i, t); //implement formula return fValue; } Now, futureValue is complete. Now, we must implement code for our main function for the compiler to execute. At this point, our program looks like this: #include <iostream> #include <cmath> using namespace std; float futureValue(float, float, int); int main() { //main code here return 0; } float futureValue(float P, float i, int t) { float fValue = 0; //future value of account fValue = P * pow(1 + i, t); //implement formula return fValue; } Note, the problem asked us to perform input validation, which means we should not accept any negative values for the present value, interest, or months. Let's start by making variables that will hold the present value, interest, months, and the final future value: int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; return 0; } Now, we should prompt for input for each of the values: int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; cout << "Enter the account's present value: "; cin >> presentValue; return 0; } At this point, we should check for input validation. If they entered a value less than 0, we should continually prompt (using a loop) for input into the same variable until the user enters a non-negative input. int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; cout << "Enter the account's present value: "; cin >> presentValue; while (presentValue < 0) { cout << "\nInvalid input. Enter the account's present value: "; // '\n' = newline character cin >> presentValue; } return 0; } The same should be done for both interest and months as well: int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; cout << "Enter the account's present value: "; cin >> presentValue; while (presentValue < 0) { cout << "\nInvalid input. Enter the account's present value: "; // '\n' = newline character cin >> presentValue; } cout << "\nEnter the account's monthly interest rate: "; cin >> monthlyInterestRate; while (monthlyInterestRate < 0) //input validation { cout << "\nInvalid input. Enter the account's monthly interest rate: "; cin >> monthlyInterestRate; } cout << "\nEnter the number of months that the money will be left in the account: "; cin >> numberOfMonths; while (numberOfMonths < 0) { cout << "\nInvalid input. Enter the number of months that\nthe money will be left in the account: "; cin >> numberOfMonths; } return 0; } Now, at this point, we should have positive values for all three components of the future value formula. We can now call to our futureValue function and pass to it the three components it needs. int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; //previous code here for prompting for input and input validation checks futureValue(presentValue, interestRate, numMonths); //not correct return 0; } The problem with our current call is that futureValue is a value-returning function, meaning that that entire statement is the equivalent to some value, ex. a '5'. That '5' is just free-floating in the program, which is an error. We should use a variable to hold that '5' by assigning a variable to that function call, such as our totalFutureValue variable: int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; //previous code here for prompting for input and input validation checks totalFutureValue = futureValue(presentValue, interestRate, numMonths); //correct return 0; } Finally, the last step is to display the future value, which we should have the correct result for in our 'totalFutureValue' variable after we made that function call. int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; //previous code here for prompting for input and input validation checks totalFutureValue = futureValue(presentValue, interestRate, numMonths); //correct cout << "\nThe account's future value will be " << totalFutureValue; //not correct return 0; } We can clean up that result a bit, because the number will be unformatted and not look appropriate for currency. We can include a new header file to help us format: #include <iomanip> This header file lets us use many input/output (io) manipulation (manip) functions for formatting, among which are setprecision(int) and fixed. Using setprecision(int) will force some number of decimal to display, depending on the integer value passed into it. For currency, we will use setprecision(2). Using fixed, the value is represented with exactly as many digits after the decimal point as defined by setprecision. For example, even if our answer is a whole number like 150, it will show 150.00. Lastly, we should include a dollar sign "$" in our cout statement to finalize the currency format. int main() { float presentValue; float interestRate; int numMonths; float totalFutureValue; //previous code here for prompting for input and input validation checks totalFutureValue = futureValue(presentValue, interestRate, numMonths); cout << "\nThe account's future value will be$" << setprecision(2) << fixed << totalFutureValue << endl; //when debugging, we can insert a pause here by either using system("pause") //or by creating a variable and prompting for input to prevent the program from closing //system("pause"); //a less-than-preferred method of pausing by programmers /* or */ //char x; //a secondary //cin >> x; //method return 0; } Example run: Enter the account's present value: 139.59 Enter the account's monthly interest rate: 0.05 Enter the number of months that the money will be left in the account: 5 The account's future value will be \$178.16.

### Subject:Algebra

TutorMe
Question:

Solve the system of equations $$x + 4y = 7$$ and $$2y - 3x = 8$$ by both substitution and addition.

Inactive
Kathleen F.
Answer:

By substitution: Solve for x in the simpler equation, where x has a coefficient of 1, by subtracting 4y from both sides: $$x + 4y = 7$$ $$x = 7 - 4y$$ Solve for x. Substitute this solution for x in the second equation: $$2y - 3x = 8$$ $$2y - 3(7 - 4y) = 8$$ Substitute solution for x. $$2y - 21 + 12y = 8$$ Distribute the -3. $$14y - 21 = 8$$ Combine like terms. $$14y = 29$$ Subtract 21 from both sides. $$y = 29/14$$ Divide both sides by 14. Substitute this solution for y in the first equation: $$x = 7 - 4y$$ $$x = 7 - 4(29/14)$$ Substitute solution for y. $$x = 7 - 116/14$$ Mulitply -4 by fraction. $$x = 7 - 58/7$$ Reduce fraction by diving it by 2/2. $$x = 49/7 - 58/7$$ Change 7 to fractional form of 49/7 to prepare for subtraction. $$x = -9/7$$ Subtract both fractions with common denominators. Check both solutions in both original equations: $$x = -9/7$$ $$y = 29/14$$ The first equation: $$x + 4y = 7$$ $$-9/7 + 4(29/14) = 7$$ Substitute solutions for x and y. $$-9/7 + 116/14 = 7$$ Multiply 4 by fraction. $$-9/7 + 58/7 = 7$$ Reduce fraction by diving it by 2/2. $$49/7 = 7$$ Add both fractions with common denominators. $$7 = 7$$ Simply 49/7 and the equation holds true for our solutions. The second equation: $$2y - 3x = 8$$ $$2(29/14) - 3(-9/7) = 8$$ Substitute solutions for x and y. $$58/14 +27/7 = 8$$ Multiply 2 by 29/14 and -3 by -9/7. $$29/7 + 27/7 = 8$$ Reduce 58/14 by diving it by 2/2. $$56/7 = 8$$ Add both fractions with common denominators. $$8 = 8$$ Simply 56/7 and the equation holds true for our solutions. Therefore, $$x = -9/7$$ and $$y = 29/14$$ are solutions for $$x + 4y = 7$$ and $$2y - 3x = 8$$. By addition: $$x + 4y = 7$$ $$2y - 3x = 8$$ Through addition, we add the both equations' left sides together and both equations' right sides together. However, we want one of the variables to cancel out for a simple solution, so we need to manipulate the equations. If I take the first equation and multiply everything by 3, I will get a $$3x$$ that will cancel out the second equation's $$-3x$$. $$x + 4y = 7$$ $$3(x + 4y) = 3(7)$$ $$3x + 12y = 21$$ Now, perform the addition of both sides. $$3x + 12y = 21$$ $$2y - 3x = 8$$ $$3x + 12y + 2y - 3x = 21 + 8$$ Add both left sides and add both right sides. $$12y + 2y = 29$$ Combine $$3x$$ and $$-3x$$ to remove x. $$14y = 29$$ Combine like terms. $$y = 29/14$$ Divide both sides by 14 to solve for y. Now, we have the solution to y which we can substitute back into either original equation to get x. $$x + 4y = 7$$ $$x + 4(29/14) = 7$$ Substitute solution for y. $$x + 116/14 = 7$$ Multiply 4 by fraction. $$x + 58/7 = 7$$ Reduce by diving fraction by 2/2. $$x = 7 - 58/7$$ Subtract 58/7 from both sides. $$x = 49/7 - 58/7$$ Change 7 to 49/7 to prepare to subtract both fractions. $$x = -9/7$$ Subtract both fractions with common denominators Now, we have $$y = 29/14$$ and $$x = -9/7$$ and can check the solutions by plugging them back into both original equations in the same way that we did for solving this problem by substitution.

## Contact tutor

Send a message explaining your
needs and Kathleen will reply soon.
Contact Kathleen

## Request lesson

Ready now? Request a lesson.
Start Lesson

## FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.