Why wont my code work? Sample code of what the input and out put should be.  Hello there! My name is CarBot. What is your name? Jane Hello Jane, it is great to meet you! Jane, where are you from? Washington Washington sounds like a pleasant place to grow up. Hmmmm, what else can I ask you... oh! What year were you born? 1950 You are 67 years old, that makes you 33.5 times as old as I am! I'm only 2 years YOUNG! What is your dream car? BMWi8 Wow, I have always wanted a BMWi8 as well. How much does a BMWi8 cost? 141695 What is a reasonable yearly interest rate (%) on a beautiful car like that? 2.0 And if you had to take out a loan to buy the BMWi8, how many years would you take the loan out for? 5 If you bought the BMWi8, you would have a monthly payment of $2483.60, hopefully that is reasonable for your budget. That's a total of $149015.76 over 5 years! I hope you can make the purchase!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Why wont my code work? Sample code of what the input and out put should be. 

Hello there! My name is CarBot. What is your name?

Jane

Hello Jane, it is great to meet you! Jane, where are you from?

Washington

Washington sounds like a pleasant place to grow up. Hmmmm, what else can I ask you... oh! What year were you born?

1950

You are 67 years old, that makes you 33.5 times as old as I am! I'm only 2 years YOUNG! What is your dream car?

BMWi8

Wow, I have always wanted a BMWi8 as well. How much does a BMWi8 cost?

141695

What is a reasonable yearly interest rate (%) on a beautiful car like that?

2.0

And if you had to take out a loan to buy the BMWi8, how many years would you take the loan out for?

5

If you bought the BMWi8, you would have a monthly payment of $2483.60, hopefully that is reasonable for your budget.


That's a total of $149015.76 over 5 years! I hope you can make the purchase! 

 

1 #include <iostream>
2 #include <<math>
3 #include <iomanip>
4 #include <string>
5 using namespace std;
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
int main()
{
// User entry of name
string userName;
cout << "What is your name?" << endl;
cin >> userName; // Only use first name. You can modify this to allow multi-word
cout << "Hi there, it is nice to meet you" << userName << endl;
// Prompt user to input location
string userFrom;
cout << "Where are you from? " << endl;
cin >> userFrom; // Only use single word. You can modify this to allow multi-word
cout << userFrom <<" sounds like a pleasant place to grow up. Hmmmm, what else can I ask you... oh! What year were you born?" << endl;
//prompting to enter birth year to calculate how old and how much older
int birthyear = 0;
int age2 = 0;
double age4 = 0;
double age3 = 0;
cin >> birthyear;
age2 2023
birthyear;
age4 = 2023.0 - birthyear;
age3 = age4/2;
cout << "You are " << age2 << " years old, that makes you " << setprecision (2)<< age3 << "times as old as I am! I'm only 2 years YOUNG! What is your dream car?"<<endl;
//dream car string and price of the car for the end calculations.
=
string car;
cin >> car;
cout << "Wow, I have always wanted a "<< car <<" as well. How much does a "<< car <<" cost? "<<endl;
double carprice = 0;
cin >> carprice;
//setting up intrest rate and for how many years.
cout <<"What is a reasonable yearly interest rate (%) on a beautiful car like that? "<<endl;
double interest = 0;
cin >> interest;
cout << "And if you had to take out a loan to buy the " << car << " how many years would you take the loan out for?"<<endl;
Activate Windows
Go to Settings to activate
Transcribed Image Text:1 #include <iostream> 2 #include <<math> 3 #include <iomanip> 4 #include <string> 5 using namespace std; 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 int main() { // User entry of name string userName; cout << "What is your name?" << endl; cin >> userName; // Only use first name. You can modify this to allow multi-word cout << "Hi there, it is nice to meet you" << userName << endl; // Prompt user to input location string userFrom; cout << "Where are you from? " << endl; cin >> userFrom; // Only use single word. You can modify this to allow multi-word cout << userFrom <<" sounds like a pleasant place to grow up. Hmmmm, what else can I ask you... oh! What year were you born?" << endl; //prompting to enter birth year to calculate how old and how much older int birthyear = 0; int age2 = 0; double age4 = 0; double age3 = 0; cin >> birthyear; age2 2023 birthyear; age4 = 2023.0 - birthyear; age3 = age4/2; cout << "You are " << age2 << " years old, that makes you " << setprecision (2)<< age3 << "times as old as I am! I'm only 2 years YOUNG! What is your dream car?"<<endl; //dream car string and price of the car for the end calculations. = string car; cin >> car; cout << "Wow, I have always wanted a "<< car <<" as well. How much does a "<< car <<" cost? "<<endl; double carprice = 0; cin >> carprice; //setting up intrest rate and for how many years. cout <<"What is a reasonable yearly interest rate (%) on a beautiful car like that? "<<endl; double interest = 0; cin >> interest; cout << "And if you had to take out a loan to buy the " << car << " how many years would you take the loan out for?"<<endl; Activate Windows Go to Settings to activate
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
PROBLEMS
cout <<"What is a reasonable yearly interest rate (%) on a beautiful car like that? "<<endl;
double interest = 0;
cin >> interest;
cout << "And if you had to take out a loan to buy the " << car << ", how many years would you take the loan out for?"<<endl;
double years = 0;
cin >> years;
int num_payments = -12 years;
double monthly_interest interest / 12.0/ 100.0;
double monthly payment = ((carprice*monthly_interest) / (1 - pow(1 + monthly_interest, num_payments)));
double total = monthly payment* (years*12);
cout <<setprecision (2)<<monthly_payment<<" "<<interest<<" "<<total<<endl;
return 0;
OUTPUT DEBUG CONSOLE TERMINAL PORTS COMMENTS
1997
You are 26 years old, that makes you 13 times as old as I am! I'm only 2 years YOUNG! What is your dream car?
ford
Wow, I have always wanted a ford as well. How much does a ford cost?
10000
What is a reasonable yearly interest rate (%) on a beautiful car like that?
1.0
And if you had to take out a loan to buy the ford, how many years would you take the loan out for?
5
1.7e+02 1 1e+04
O @Conme15 →/workspaces/pa3-Conme15 (master) $
DO AO AO
Transcribed Image Text:39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 PROBLEMS cout <<"What is a reasonable yearly interest rate (%) on a beautiful car like that? "<<endl; double interest = 0; cin >> interest; cout << "And if you had to take out a loan to buy the " << car << ", how many years would you take the loan out for?"<<endl; double years = 0; cin >> years; int num_payments = -12 years; double monthly_interest interest / 12.0/ 100.0; double monthly payment = ((carprice*monthly_interest) / (1 - pow(1 + monthly_interest, num_payments))); double total = monthly payment* (years*12); cout <<setprecision (2)<<monthly_payment<<" "<<interest<<" "<<total<<endl; return 0; OUTPUT DEBUG CONSOLE TERMINAL PORTS COMMENTS 1997 You are 26 years old, that makes you 13 times as old as I am! I'm only 2 years YOUNG! What is your dream car? ford Wow, I have always wanted a ford as well. How much does a ford cost? 10000 What is a reasonable yearly interest rate (%) on a beautiful car like that? 1.0 And if you had to take out a loan to buy the ford, how many years would you take the loan out for? 5 1.7e+02 1 1e+04 O @Conme15 →/workspaces/pa3-Conme15 (master) $ DO AO AO
Expert Solution
Step 1: Corrected code

Below is the C++ code:

1#include <iostream>
2#include <iomanip>
3#include <string>
4#include <cmath>
5
6using namespace std;
7
8int main()
9{
10    // User entry of name
11    string userName;
12    cout << "Hello there! My name is CarBot. What is your name?" << endl;
13    cin >> userName; // Only use first name. You can modify this to allow multi-word
14    cout << "Hello " << userName << " it is great to meet you!" << userName << ", ";
15
16    // Prompt user to input location
17    string userFrom;
18    cout << "where are you from?" << endl;
19    cin >> userFrom; // Only use single word. You can modify this to allow multi-word
20    cout << userFrom << " sounds like a pleasant place to grow up. Hmmmm, what else can I ask you... oh! What year were you born?" << endl;
21
22    // Prompting to enter birth year to calculate age
23    int birthYear = 0;
24    cin >> birthYear;
25    int age = 2023 - birthYear;
26    cout << "You are " << age << " years old, that makes you " << setprecision(2) << fixed << static_cast<double>(age) / 2 << " times as old as I am! I'm only 2 years YOUNG! What is your dream car?" << endl;
27
28    // Dream car string and price of the car for the end calculations
29    string car;
30    cin >> car;
31    cout << "Wow, I have always wanted a " << car << " as well. How much does a " << car << " cost?" << endl;
32
33    double carPrice = 0;
34    cin >> carPrice;
35
36    // Setting up interest rate and for how many years
37    cout << "What is a reasonable yearly interest rate (%) on a beautiful car like that?" << endl;
38    double interest = 0;
39    cin >> interest;
40
41    cout << "And if you had to take out a loan to buy the " << car << ", how many years would you take the loan out for?" << endl;
42    int years = 0;
43    cin >> years;
44
45    int numPayments = -12 * years;
46    double monthlyInterest = interest / 12.0 / 100.0;
47    double monthlyPayment = (carPrice * monthlyInterest) / (1 - pow(1 + monthlyInterest, numPayments));
48    double totalPayment = monthlyPayment * (years * 12);
49
50    // Outputting the monthly and total payment
51    cout << "If you bought the " << car << ", you would have a monthly payment of $" << monthlyPayment << ", hopefully that is reasonable for your budget." << endl;
52    cout << "That's a total of $" << totalPayment << " over " << years << " years!" << " I hope you can make the purchase!" << endl;
53
54    return 0;
55}
56


steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education