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...
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...
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...
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...
Write a Java program that asks the user to enter an integer that is used to...
Write a Java program that asks the user to enter an integer that is used to set a limit that will generate the following four patterns of multiples of five using nested loops •Ascending multiples of five with ascending length triangle •Ascending multiples of five with descending length (inverted) triangle •Descending multiples of five with ascending length triangle •Descending multiples of five with descending length (inverted) triangle Use error checking to keep asking the user for a positive number until...
Write a program that asks the user to enter an unsigned number and read it. Then...
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6. COMMENT COMPLETE CODE PLEASE
In a file called LengthSum.java, write a program that: - Asks the user to enter a...
In a file called LengthSum.java, write a program that: - Asks the user to enter a string. - Asks the user to enter a second string. - Prints out the length of the first string, the length of the second string, and the sum of the two lengths, using EXACTLY the same format as shown below. For example: if the user enters strings "UT" and "Arlington", your program output should look EXACTLY like this: Please enter a string: UT Please...
Using Python Write a program that does the following in order: 1.     Asks the user to enter...
Using Python 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 the Federal tax, FICA...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT