Question

In: Computer Science

PART A A student wants to purchase an investment property that can generate sufficient cash flow...

PART A

A student wants to purchase an investment property that can generate sufficient cash flow (net rental income) to pay her monthly living expenses. The cash flow is calculated by taking the rent received in a month and subtracting all of the expenses associated with the property for that month.
The expenses are:
landlord insurance
property taxes
repair cost
management fees

Write a program to calculate the net income and determine if it’s sufficient to pay the living expenses.

In addition to main(), also use the following five functions in your program:  

getIncomeNeeded() : a value-returning function that asks for the income needed to pay the monthly living expenses. Use a return statement to send it to main().

getRentalIncome() : a value-returning function that asks for the rental income received monthly. Use a return statement to send it to main().

getRentalExpenses() : a value-returning function that asks for all the expense amounts and returns the total expense. Use a return statement to send it to main().

calculateCashFlow() : a value-returning function that calculates the cash flow (net income) tomain().

canPayLivingExpenses(…): a value-returning function that returns true or false (true: can pay living expenses and false: cannot pay living expenses) – Display message in main() based on this return value.

(Part B)

Write a C++ program which prompts user to choose from the two alternative funtions specified below, each of which passes a random number between 1 and 4 and returns a random message.

The two functions are:
Function messageByValue that passes a random value between 1 and 4 and returns the message by value and
Function messageByReference that passes a random value between 1 and 4 and returns the message by reference.

Each function returns one of four random messages:
- “Sorry. You’re busted!”
- “Oh, you’re going for broke, huh?”
- “Aw cmon, take a chance!”
- You’re up big. Now’ the time to cash in your chips”

NOTE:
Use a while loop to continually run program until a -1 is entered to Terminate program.

Solutions

Expert Solution

// PART A

#include <iostream>

using namespace std;

int getIncomeNeeded() {

int livingExpenses;

cout << "Enter income needed to pay living expenses: ";

cin >> livingExpenses;

return livingExpenses;

}

int getRentalIncome() {

int rentalIncome;

cout << "Enter rental income: ";

cin >> rentalIncome;

return rentalIncome;

}

int getRentalExpenses() {

int rentalExpenses = 0, expense;

cout << "Enter landlord insurance: ";

cin >> expense;

rentalExpenses += expense;

cout << "Enter property taxes: ";

cin >> expense;

rentalExpenses += expense;

cout << "Enter repair cost: ";

cin >> expense;

rentalExpenses += expense;

cout << "Enter management fees: ";

cin >> expense;

rentalExpenses += expense;

return rentalExpenses;

}

int calculateCashFlow(int rentalIncome, int rentalExpenses) {

return rentalIncome - rentalExpenses;

}

bool canPayLivingExpenses(int livingExpenses, int cashFlow) {

return livingExpenses < cashFlow;

}

int main() {

int livingExpenses = getIncomeNeeded();

int rentalIncome = getRentalIncome();

int rentalExpenses = getRentalExpenses();

int cashFlow = calculateCashFlow(rentalIncome, rentalExpenses);

if (canPayLivingExpenses(livingExpenses, cashFlow))

cout << "Can pay living expenses." << endl;

else

cout << "Cannot pay living expenses." << endl;

return 0;

}

// . PART B

#include <iostream>

#include <string>

#include <cstdlib>

using namespace std;

string messageByValue(int value) {

switch(value) {

case 1: return "Sorry. You’re busted!";

case 2: return "Oh, you’re going for broke, huh?";

case 3: return "Aw cmon, take a chance!";

case 4: return "You’re up big. Now’ the time to cash in your chips";

}

return NULL;

}

void messageByReference(int value, string &message) {

switch(value) {

case 1: message = "Sorry. You’re busted!"; break;

case 2: message = "Oh, you’re going for broke, huh?"; break;

case 3: message = "Aw cmon, take a chance!"; break;

case 4: message = "You’re up big. Now’ the time to cash in your chips";

}

}

int main() {

while(true) {

cout << "Enter your choice of function (1 for messageByValue, 2 for messageByReference) or -1 to exit: ";

int choice;

cin >> choice;

if (choice == -1)

break;

else if (choice == 1) {

string message;

message = messageByValue(rand() % 4 + 1);

cout << message << endl;

}

else if (choice == 2) {

string message;

messageByReference(rand() % 4 + 1, message);

cout << message << endl;

}

}

return 0;

}


Related Solutions

You want to save sufficient funds to generate an annual cash flow of $55,000 a year...
You want to save sufficient funds to generate an annual cash flow of $55,000 a year for 25 years as retirement income. You currently have no retirement savings but plan to save an equal amount each year for the next 38 years until your retirement. How much do you need to save each year if you can earn 7.5 percent on your savings?
An investment is expected to generate annual cash flows forever. The first annual cash flow is...
An investment is expected to generate annual cash flows forever. The first annual cash flow is expected in 1 year and all subsequent annual cash flows are expected to grow at a constant rate annually. We know that the cash flow expected in 3 years from today is expected to be $9,000 and the cash flow expected in 7 years from today is expected to be $10,000. What is the cash flow expected to be in 5 years from today?
An investment is expected to generate annual cash flows forever. The first annual cash flow is...
An investment is expected to generate annual cash flows forever. The first annual cash flow is expected in 1 year and all subsequent annual cash flows are expected to grow at a constant rate annually. We know that the cash flow expected in 2 year(s) from today is expected to be 1,860 dollars and the cash flow expected in 8 years from today is expected to be 3,140 dollars. What is the cash flow expected to be in 5 years...
1. The best measure of a company's ability to generate sufficient cash is cash provided by:...
1. The best measure of a company's ability to generate sufficient cash is cash provided by:             a.   financing activities.             b.   investing activities.             c.   operating activities.             d.   processing activities.             e.    None of the above. 2. A company's cash flow from investingactivities includes a. cash paid for common dividends. b. cash received from issuance of common stock. c. cash received from sale of plant equipment.                        d. cash paid for employee salaries. e. Both a and b 3. A company's cash flow from operating activities includes a. cash...
Suppose you are considering an investment that will generate equal annual cash flow of $200,000 over...
Suppose you are considering an investment that will generate equal annual cash flow of $200,000 over its 10-year life, resulting in an IRR of 14% and a Profitability index of 1.05. What is this investment's NVP?
Draw the cash flow: Your aunt Carry wants to purchase a 200K piece of equipment for...
Draw the cash flow: Your aunt Carry wants to purchase a 200K piece of equipment for her factory, operations cost will be 20K a year as well as a 80K fee at the end of year three. By year seven your aunt would be able to resell the piece of equipment for 15K
Suppose a property can be bought for $2,500,000 and it will provide $200,000/year net cash flow...
Suppose a property can be bought for $2,500,000 and it will provide $200,000/year net cash flow forever, and you can borrow a perpetual interest-only mortgage secured by that property at a 7% interest rate, up to an amount of $950,000. (a) Does this present “positive” or “negative leverage,” and (b) why? (c) Do you think that the use of leverage, in this case, will increase the NPV of the investment for the equity investor in the property? (d) Why or...
Describe and explain three different cash flows: operating cash flow, investment cash flow, and cash flow...
Describe and explain three different cash flows: operating cash flow, investment cash flow, and cash flow from financing activities. What is the relative importance of each, and what factors impact your assessment? Does it vary by industry or business maturity? Imagine that you were structuring a business from the ground up--what percentage of cash flow would you target for each of these three types?
Tom wants to purchase a property for $300,000. He can borrow a 80% LTV fixed-rate loan,...
Tom wants to purchase a property for $300,000. He can borrow a 80% LTV fixed-rate loan, with 4.5% annual interest rate and a 3% origination fee. Or, he can borrow a 90% LTV fixed-rate loan, with 5.5% annual interest rate, and a 3% origination fee. Both loans have a 30 year amortization period. If he plans to prepay the loan at the end of 3rd year, what will be the incremental cost of borrowing for him to to borrow the...
Listed below are yearly forecasts of “free cash flow” (operating cash flow plus investment-related cash flow)...
Listed below are yearly forecasts of “free cash flow” (operating cash flow plus investment-related cash flow) for Tomkat LLC. Year Cash Flow 2020 -$2.8 million. 2021 -$2.0 million. 2022 -$1.2 million. 2023 -$0.2 million. 2024 $0.9 million. 2025 $2.2 million. After year 2025, cash flows are anticipated to grow by 3% per year, in perpetuity. For simplicity, assume all that cash flows occur at the end of each year. Assume a discount rate of 8% per year. What is the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT