Question

In: Computer Science

Write a program that asks the user to enter the monthly costs for the following expenses...

Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile:

Loan payment
Insurance
Gas
Oil
Tires
Maintenance
Write a function that takes these six items as arguments and computes the total cost of these expenses.

Write a main program that asks the user for these six items and calls your function.

Print total monthly cost and the total annual cost for these expenses.

Solutions

Expert Solution

#include <iostream>
using namespace std;

// function to compute monthly cost
double monthly_cost(double loan,double Insurance,double Gas,double Oil,double Tires,double Maintenance)
{
  double cost = loan+Insurance+Gas+Oil+Tires+Maintenance;
  return cost;
}
int main() {
  //variable declaration
  double loan,Insurance,Gas,Oil,Tires,Maintenance;
  //user input
  cout<<"Enter monthly cost for loan:\n";
  cin>>loan;
  cout<<"Enter monthly cost for insurance:\n";
  cin>>Insurance;
  cout<<"Enter monthly cost for gas:\n";
  cin>>Gas;
  cout<<"Enter monthly cost for oil:\n";
  cin>>Oil;
  cout<<"Enter monthly cost for tires:\n";
  cin>>Tires;
  cout<<"Enter monthly cost for maintenance:\n";
  cin>>Maintenance;
  //calculate total monthly cost
  double total_monthly_cost = monthly_cost(loan,Insurance,Gas,Oil,Tires,Maintenance);
  //calculate total monthly cost
  double total_annually_cost = total_monthly_cost*12;
  //print output
  cout<<"\nTotal Monthly cost for expenses incurred from operating his or her automobile is: "<<total_monthly_cost;

  cout<<"\n\nTotal Annual cost for expenses incurred from operating his or her automobile is: "<<total_annually_cost;


}

Output::

Note/:: If you have any queries Comment I will solve anything


Related Solutions

Write a program that asks the user to enter the monthly costs for the following expenses...
Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. Using the following test data: 310.34 104.95 78.34 12.34 8.12 45.00 Your output should look like this: Enter the monthly loan payment amount: Enter the monthly cost of insurance:...
Write a C++ program that asks the user to enter the monthly costs for the following...
Write a C++ program that asks the user to enter the monthly costs for the following expenses incurred from operating your automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and a projected total annual cost of these expenses. Label each cost. The labels should be left aligned and have a column width of 30 characters. The cost should be aligned right and displayed with two decimal places...
Write a Python program that asks the user to enter the monthly costs for the following...
Write a Python program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: Loan payment Insurance Gas Oil Tires Maintenance Write a function that takes these six items as arguments and computes the total cost of these expenses. Write a main program that asks the user for these six items and calls your function. Print total monthly cost and the total annual cost for these expenses. Your function should...
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Q2. Design a Pearson modular program that asks the user to enter the monthly costs for...
Q2. Design a Pearson modular program that asks the user to enter the monthly costs for each of the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, and maintenance (create a module for each expense). The program should then display the total monthly cost of these expenses, and the total annual cost of these expenses in the main Module. Use Pass arguments By Reference method to design your modules. Submit your pseudocode with comments at...
In python, write a program that asked the user to enter the monthly costs for the...
In python, write a program that asked the user to enter the monthly costs for the following expenses incurred from operating his automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should display total monthly cost and annual cost. Also, should contain main and calcExpenses functions, calcExpenses should only calculate the expenses and everything else should happen in the main function.
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
Write a program that asks the user to enter a number. Display the following pattern by...
Write a program that asks the user to enter a number. Display the following pattern by writing lines of asterisks. The first line will have one asterisk, the next two, and so on, with each line having one more asterisk than the previous line, up to the number entered by the user.For example, if the user enters 5, the output would be: * *   * *   *   * *   *   *   * *   *   *   *   * short codes please
Write a program that does the following in order: 1. Asks the user to enter a...
Write a program that does the following in order: 1. Asks the user to enter a name 2. Asks the user to enter a number “gross income” 3. Asks the user to enter a number “state tax rate” 4. Calculates the “Federal Tax”, “FICA tax” and “State tax” 5. Calculates the “estimated tax” and round the value to 2 decimal places 6. Prints values for “name”, “gross income” and “estimated tax” The program should contain three additional variables to store...
Program should be written in Java a) Write a program that asks the user to enter...
Program should be written in Java a) Write a program that asks the user to enter the approximate current population of India. You should have the computer output a prompt and then YOU (as the user should enter the population.)  For testing purposes you may use the value of 1,382,000,000 from August 2020. Assume that the growth rate is 1.1% per year. Predict and print the predicted population for 2021 and 2022. The printout should include the year and the estimated...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT