57.7k views
5 votes
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (current_price * 0.051) / 12. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:

2 Answers

3 votes

Final answer:

The student's question involves writing programs in C++ and Python to summarize current house price, change since last month, and estimate the monthly mortgage. Example codes in both languages are provided, offering a clear and concise way to calculate and present the required financial information.

Step-by-step explanation:

As a solution to the student's request, we can provide a simple program in both C++ and Python to calculate the summary of a house pricing including the current price, the change since last month, and the estimated monthly mortgage. Below are example codes for both languages:

C++ Program:

#include
#include

int main() {
int currentPrice, lastMonthsPrice;
std::cin >> currentPrice >> lastMonthsPrice;
double change = currentPrice - lastMonthsPrice;
double monthlyMortgage = (currentPrice * 0.051) / 12;

std::cout << std::fixed << std::setprecision(2);
std::cout << "Current Price: $" << currentPrice << "\\";
std::cout << "Change Since Last Month: $" << change << "\\";
std::cout << "Estimated Monthly Mortgage: $" << monthlyMortgage << std::endl;

return 0;
}

Python Program:

current_price = int(input())
last_months_price = int(input())

change = current_price - last_months_price
monthly_mortgage = (current_price * 0.051) / 12

print(f'Current Price: ${current_price:.2f}')
print(f'Change Since Last Month: ${change:.2f}')
print(f'Estimated Monthly Mortgage: ${monthly_mortgage:.2f}')

By inputting the current and last month's house prices, these programs will output a formatted summary that includes change in price and monthly mortgage estimate.

User Akshay Nandwana
by
4.6k points
4 votes

Answer:

Check the explanation

Step-by-step explanation:

Coral Program:

//Declaring variables

integer currentPrice

integer lastMonthPrice

integer changeLastMonth

float mortagage

//Reading input

currentPrice = Get next input

lastMonthPrice = Get next input

//Calculating price change

changeLastMonth = currentPrice - lastMonthPrice

//Calculating mortagage

mortagage = (currentPrice * 0.045) / 12

//Printing output

Put "This house is $" to output

Put currentPrice to output

Put "\\The change is $" to output

Put changeLastMonth to output

Put " since last month." to output

Put "\\The estimated monthly mortgage is $" to output

Put mortagage to output

___________________________________________________________________________________________

Kindly check the attached image below for the sample output.

Sites like Zillow get input about house prices from a database and provide nice summaries-example-1
User George Shore
by
4.2k points