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