15.2k views
2 votes
2.32 LAB: Input and formatted output: House real estate summary 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.051) / 12 (Note: Output directly as a floating-point value. Do not store in a variable.). 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 $850.000000. Note: Getting the precise spacing, punctuation, and newlines exactly right is a key point of this assignment. Such precision is an important part of programming.

2 Answers

2 votes

Final answer:

To solve the student's problem, input the current and last month's house prices, calculate the price change, compute the estimated mortgage, and correctly format the output presenting the figures.

Step-by-step explanation:

To create a program that takes the current price and last month's price of a house as inputs, and outputs a summary of the price change and estimated monthly mortgage, follow these instructions:

  1. First, prompt the user to input both the current price and the last month's price of the house.
  2. Calculate the difference between the current price and the last month's price.
  3. Compute the estimated monthly mortgage using the formula ((currentPrice * 0.051) / 12).
  4. Finally, format the output to include the current price, the price change, and the mortgage estimate. Ensure that spaces, punctuation, and newlines match the example precisely.

Here's how the output should look like:

This house is $200000. The change is $-10000 since last month. The estimated monthly mortgage is $850.000000.

User Hashira
by
4.5k points
6 votes

Answer:

C++.

Step-by-step explanation:

int main() {

int current_price, last_months_price;

// Inputs

cin<<current_price;

cout<<endl;

cin<<last_months_price;

cout<<endl;

// Outputs

cout<<"This house is $"<<current_price<<endl;

cout<<"The change is $"<<(current_price - last_months_price)<<endl;

cout<<"The estimated monthly mortgage is $"<<((current_price * 0.051) / 12);

return 0;

}

User Sefiroths
by
4.3k points