Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question : You've been asked to write a program that computes percentages for specific categories in a personal budget. The program should ask the user

Question : You've been asked to write a program that computes percentages for specific categories in a personal budget. The program should ask the user to enter estimated monthly expenditures for the following categories: Rent Payment, Food, Utilities, and All Other. Your program should add the amounts, display the total, and compute and display the percentage for each category. Dollar amounts should be displayed with two decimal places and percentages should be displayed with one decimal place.

Note -The user will enter, from the keyboard, dollar amounts like 700.00 for rent. Add two additional categories to your code for a total of 6 categories (Rent, Food, Utilities, Your Category1, Your Category2, All Others). So your JavaScript code will use 6 different variables - one for each catagory (do not use an array as that data structure is not covered till much later in the book). You will have to use a prompt box to obtain the dollar amounts from the user. Remember to make the statement in the prompt box clear and concise (so the user knows exactly for which category they are entering the amount). Your JavaScript will convert each category of expenses to a percentage. The math to do this is to first add all of the dollar amounts entered for all of the categories; then divide each category's dollar value by that total and multiply the result by 100. You can check your math by adding the percentages of all the categjories; the total should be 100. Remember that any content entered into a variable from a prompt statement is considered a character by JavaScript....... so remember to use parseFloat to convert the value to an actual number.

Your JavaScript will display, in the document window of a web page (not in an alert box), the category name, the dollar amount entered by the user for each category, and the converted percentage calculated by your code. Submit BOTH the notepad document with the pseudocode and the working HTML/JavaScript document.To display the amounts and percentages with 2 decimal places - use the code: total = total.toFixed(2); this line of JavaScript code will assign to the variable total the amount entered into the total variable by the user to an amount with 2 decimal places ( so 700 will print as 700.00 and 500.26555 will print as 500.27).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions