193k views
4 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 (currentPrice * 0.045) / 12. Ex: If the input is 200000 210000, the output is: This house is $200000. The change is $-10000 since last month. The estimated monthly mortgage is $750

2 Answers

2 votes

Answer:

current_price = int(input())

last_months_price = int(input())

finalprice= current_price-last_months_price

monthly= (current_price*0.051)/12

print('This house is', '$''{:.0f}'.format(current_price),end='.')

print(' ''The change is', '$''{:.0f}'.format(finalprice), 'since last month.')

print('The estimated monthly mortgage is', '$''{:.2f}'.format(monthly),end='.''\\')

Step-by-step explanation:

User Eshirvana
by
4.7k points
5 votes

Answer:

Here is code in c++.

#include <bits/stdc++.h>

using namespace std;

//main function

int main() {

// variables to store input and calculate price change and mortgage

int current_price,last_price,change;

float mortgage=0;

cout<<"Please enter the current month price:";

//reading current month price

cin>>current_price;

cout<<"Please enter the last month price:";

//reading last month price

cin>>last_price;

// calculating difference

change=current_price-last_price;

// calculating mortgage

mortgage=(current_price*0.045)/12;

//printing output

cout<<"The change is $"<<change<<" since last month."<<endl;

cout<<"The estimated monthly mortgage is $"<<mortgage<<endl;

return 0;

}

Step-by-step explanation:

Read the current month price and assign it to "current_price" and last month

price to variable "last_price". Calculate change from last month by subtracting

current_price-last_price.And then calculate monthly mortgage as (current_price*0.045)/12. Then print the output.

Output:

Please enter the current price:200000

Please enter the last month price:210000

The change is $-10000 since last month.

The estimated monthly mortgage is $750

User Song Bee
by
4.8k points