Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello Can someone help me with this super easy C++ program. I am super new to pr

ID: 3664536 • Letter: H

Question

Hello Can someone help me with this super easy C++ program. I am super new to programming. Below is the code I have so far. I would like to make two functions--one is menu and one is creditScore and add them to mainIf someone can fix all the errors I have so fat that will be great.

#include <cstdlib>

#include <iostream>

#include <cmath>

using namespace std;

int main(int argc, char *argv[])

{

float cost;

menu();

creditScore();

}

char menu()

{

int n;

float cost;

//this is the menu which is displayed to user. I have used only 4 car makers. you can add or delete more.

cout << "Welcome to Car Shop" << endl;

cout << "Please enter your choice" << endl;

cout << "1. Ford" << endl;

cout << "2. Honda" << endl;

cout << "3. Audi" << endl;

cout << "4. Royals Roece" << endl;

// ask user to enter their choice

cin >> n;

//select case according to user choice

switch (n)

{

case 1:

{

cout << "The price of car you choose is: $25000" << endl;

cost = 25000;

break;

}

case 2:

{

cout << "The price of car you choose is: $20000" << endl;

cost = 20000;

break;

}

case 3:

{

cout << "The price of car you choose is: $30000" << endl;

cost = 30000;

break;

}

case 4:

{

cout << "The price of car you choose is: $50000" << endl;

cost = 50000;

break;

}

default:

{

cout << "Invalid choice" << endl;

return 0;

}

}

}

char creditScore()

{

int rate

double CS, cost, amount1, amount2, amount3, amount4, DP; // DP represents downpayment.

char DPC; //DPC represents whether the people wdownt a downpayment

// ask user to enter credit scoreant to pu

cout << "Please enter your credit score" << endl;

cin >> CS;

//select rate of interest on the basis of credit score

if (CS <= 500)

rate = 5;

else if (CS>500 && CS <= 700)

rate = 2;

else

rate = 1;

cout << "The rate of interest on your car is " << rate << "%" << endl;

//ask user to put down payment

cout << "Would you prefer to put down payment for the car.(Y/N)" << endl;

cin >> DPC;

if (DPC == 'Y' || DPC == 'y')

{

cout << "Please enter down Payment" << endl;

cin >> DP;

}

// finally calculate monthly installment

amount1 = ((cost - DP)*pow((1 + (rate / 100)), 1)) / (12 * 1);

amount2 = ((cost - DP)*pow((1 + (rate / 100)), 2)) / (12 * 2);

amount3 = ((cost - DP)*pow((1 + (rate / 100)), 3)) / (12 * 3);

amount4 = ((cost - DP)*pow((1 + (rate / 100)), 4)) / (12 * 4);

cout << "Monthly installment for 1 years is " << amount1 << endl;

cout << "Monthly installment for 2 years is " << amount2 << endl;

cout << "Monthly installment for 3 years is " << amount3 << endl;

cout << "Monthly installment for 4 years is " << amount4 << endl;

system("PAUSE");

return EXIT_SUCCESS;

}

Explanation / Answer

#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
char menu();
char creditScore(float );
int main()
{
char crs;
int m;
m=menu();
crs=creditScore(m);
cout << m << endl;
cout << crs << endl;
}
char menu()
{
int n; float cost;
cout << "Welcome to Car Shop" << endl;
cout << "Please enter your choice" << endl;
cout << "1. Ford" << endl;
cout << "2. Honda" << endl;
cout << "3. Audi" << endl;
cout << "4. Royals Roece" << endl;
cin >> n; // ask user to enter their choice
//select case according to user choice
switch (n)
{
case 1:
cout << "The price of car you choose is: $25000" << endl;
cost = 25000;
return cost;
break;
case 2:

cout << "The price of car you choose is: $20000" << endl;
cost = 20000;
return cost;
break;
case 3:
cout << "The price of car you choose is: $30000" << endl;
cost = 30000;
return cost;
break;
case 4:
cout << "The price of car you choose is: $50000" << endl;
cost = 50000;
return cost;
break;

default:
cout << "Invalid choice" << endl;
return 0;
}
}
char creditScore(float cost)
{
   int rate;
   float CS, amount1, amount2, amount3, amount4, DP; // DP represents downpayment.
char DPC; // DPC represents whether the people wdownt a downpayment
// ask user to enter credit scoreant to pu
cout << "Please enter your credit score" << endl;
cin >> CS;
//select rate of interest on the basis of credit score
if (CS <= 500)
rate = 5;
else
if (CS>500 && CS <= 700)
rate = 2;
else
rate = 1;
cout << "The rate of interest on your car is " << rate << "%" << endl;
//ask user to put down payment
cout << "Would you prefer to put down payment for the car.(Y/N)" << endl;
cin >> DPC;
if (DPC == 'Y' || DPC == 'y')
{
cout << "Please enter down Payment" << endl;
cin >> DP;
}
// finally calculate monthly installment
amount1 = ((cost - DP)*pow((1 + (rate / 100)), 1)) / (12 * 1);
amount2 = ((cost - DP)*pow((1 + (rate / 100)), 2)) / (12 * 2);
amount3 = ((cost - DP)*pow((1 + (rate / 100)), 3)) / (12 * 3);
amount4 = ((cost - DP)*pow((1 + (rate / 100)), 4)) / (12 * 4);
cout << "Monthly installment for 1 years is " << amount1 << endl;
cout << "Monthly installment for 2 years is " << amount2 << endl;
cout << "Monthly installment for 3 years is " << amount3 << endl;
cout << "Monthly installment for 4 years is " << amount4 << endl;
system("PAUSE");
return EXIT_SUCCESS;
}

// i changed some contents added some varriable and check compilation has no error run it

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote