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, 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:

Enter the monthly cost of gas:

Enter the monthly cost of oil:

Enter the monthly cost of tires:

Enter the monthly cost of maintenance:

The total monthly cost is $559.09.
The total annual cost is $6709.08.

This is C++ and use visual studio 2017 please.

Use blank lines to separate the major parts of your main function. And show your output.

Solutions

Expert Solution

//################### PGM START ########################################


#include<iostream>

using namespace std;

//main method
int main(){
  
   //varibles to hold different values
   double loan;
   double insurance;
   double gas;
   double oil;
   double tries;
   double maintenance;
   double monthly;
   double yearly;
  
   //requesting loan amount from user
    cout<<"Enter the monthly loan payment amount:";
    cin>>loan;
  
   //requesting insurance amount from user
   cout<<"Enter the monthly cost of insurance:";
   cin>>insurance;
  
   //requesting gas amount from user
   cout<<"Enter the monthly cost of gas:";
   cin>>gas;

   //requesting oil cost from user
   cout<<"Enter the monthly cost of oil:";
   cin>>oil;
  
   //requesting cost for tries
   cout<<"Enter the monthly cost of tires:";
   cin>>tries;

   //requesting cost for maintenance
   cout<<"Enter the monthly cost of maintenance:";
   cin>>maintenance;

   //calculating the monthly cost
   monthly=loan+insurance+gas+tries+maintenance+oil;
   //claculating the yearly cost
   yearly=12*monthly;
  
   //pdisplaying the results
   cout<<"\nThe total monthly cost is $"<<monthly<<"\n";
   cout<<"The total annual cost is $"<<yearly<<"\n";
   return 0;
}

//##################### PGM END ####################################

OUTPUT
########

ClUsersIBM_ADMIN Desktop MAIN _FOLDERVoblPGMs\AutomobileCharge.exe Enter the monthly loan payment amount: 310.34 Enter the monthly cost of insurance 104.95 Enter the monthly cost of gas: 78.34 Enter the monthly cost of oil: 12.34 Enter the monthly cost of tires: 8.12 Enter the monthly cost of maintenance 45.00 The total monthly cost is $559.09 The total annual cost is $6709.08 Process exited after 26.05 seconds with return value 0 Press any key to continue . .


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 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.
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