Write a program that determines the number of years it will take a home to double in value given the current value of the home and the predicted appreciation rate. Example A interleaved input and output with inputs 100000 and 0.042 Enter home value: 100000 Enter appreciation rate (3.8% enter as 0.038):0.042 It will take about 17 years to double in value. Example B interleaved input and output with an invalid input value: Enter home value: 10000000 Enter appreciation rate (3.8% enter as 0.038) : unknown Unexpected value: unknown

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
6.15 **zyLab: Home Value (Required & Human Graded)
Write a program that determines the number of years it will take a home to double in value given the current value of the home and the
predicted appreciation rate.
Example A
interleaved input and output with inputs 100000 and 0.042
Enter home value: 100000
Enter appreciation rate (3.8% enter as 0.038):0.042
It will take about 17 years to double in value.
Example B
interleaved input and output with an invalid input value:
Enter home value: 10000000
Enter appreciation rate (3.8% enter as 0.038) : unknown
Unexpected value: unknown
Transcribed Image Text:6.15 **zyLab: Home Value (Required & Human Graded) Write a program that determines the number of years it will take a home to double in value given the current value of the home and the predicted appreciation rate. Example A interleaved input and output with inputs 100000 and 0.042 Enter home value: 100000 Enter appreciation rate (3.8% enter as 0.038):0.042 It will take about 17 years to double in value. Example B interleaved input and output with an invalid input value: Enter home value: 10000000 Enter appreciation rate (3.8% enter as 0.038) : unknown Unexpected value: unknown
Algorithm
For example, for a home valued at $100,000 and a predicted appreciation rate of 3.8%, we could start writing the code as:
homeValue = 100000.0;
years = 0;
//after one year
homeValue = homeValue + homeValue * 0.038;
years++;
//after two years
home Value = homeValue +homeValue * 0.038;
years++;
//after three years
homeValue = homeValue + homeValue * 0.038;
years++;
//... keep going until the home value doubles the initial value. What kind of loop would be
most appropriate here?
after 19 years the value is anticipated to be about $203,118, so it takes 19 years to double.
Class HomeValue with two methods
Create a class named HomeValue. Within the class write a method that has the current home value and predicted appreciation rate as
parameters of type double and returns the number of years required to double in value. There should not be any input or output within this
method. The method name should be a verb or verb phrase that describes what the method does and not how it is used.
The main method prompts the user for the home value and predicted appreciation rate. With valid input values main calls the other method
to calculate the number of years. Print out the resulting number of years in the main method.
Error checking: Check if the user entered values can be converted to double values, if not then the program ends with the message
"Unexpected value:" as shown in the example output.
Transcribed Image Text:Algorithm For example, for a home valued at $100,000 and a predicted appreciation rate of 3.8%, we could start writing the code as: homeValue = 100000.0; years = 0; //after one year homeValue = homeValue + homeValue * 0.038; years++; //after two years home Value = homeValue +homeValue * 0.038; years++; //after three years homeValue = homeValue + homeValue * 0.038; years++; //... keep going until the home value doubles the initial value. What kind of loop would be most appropriate here? after 19 years the value is anticipated to be about $203,118, so it takes 19 years to double. Class HomeValue with two methods Create a class named HomeValue. Within the class write a method that has the current home value and predicted appreciation rate as parameters of type double and returns the number of years required to double in value. There should not be any input or output within this method. The method name should be a verb or verb phrase that describes what the method does and not how it is used. The main method prompts the user for the home value and predicted appreciation rate. With valid input values main calls the other method to calculate the number of years. Print out the resulting number of years in the main method. Error checking: Check if the user entered values can be converted to double values, if not then the program ends with the message "Unexpected value:" as shown in the example output.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY