Question: (Javascript/html) Build a JavaScript program that prompts the user for the amount of rain received and the type of fertilizer used. It uses this information

(Javascript/html) Build a JavaScript program that prompts the user for the amount of rain received and the type of fertilizer used. It uses this information to calculate how much grain an acre of land produces (here we call this the "yield"). Build Specifications: Prompt the user for the amount of rain in inches. Create a string with the same number of asterisk (*) characters as inches of rain entered by the user. Console log the string. Determine how the yield is affected by the rain... Normally the land produces 50 bushels of grain. But if there's too much rain (20 inches or more), that number goes down by 10%. Or if there's too little rain (less than 10 inches), that number goes down by 20%. Prompt the user whether they used fertilizer. The user should enter "yes" or "no". If the user said "yes", prompt them what type of fertilizer they used. The user should enter "premium" or "regular". Starting with the yield that you already calculated based on the rain, adjust that number based on the fertilizer. There are three possibilities. No fertilizer: Do not change the yield. Regular fertilizer: Add 10% to the yield. Premium fertilizer: Add 15% to the yield. Finally console log to display the result.

The folder should contain: index.html a folder named js that will contain the script file named script.js The script.js file must be linked within the element of your index.html. The script.js file will contain all of the code required to complete the challenge.

Example run 1 (user input in bold): (prompt) How many inches of rain fell? 30 (console) Rain: ****************************** (prompt) Did you use fertilizer? yes (prompt) Did you use premium or regular fertilizer? premium (console) The yield should be 51.75 bushels per acre. Explanation: Having too much rain subtracted 10% from 50, leaving 45. Then premium fertilizer added 15%, to 45, which is 51.75. Example Run 2: (prompt) How many inches of rain fell? 8 (console) Rain: ******** (prompt) Did you use fertilizer? no (console) The yield should be 40 bushels per acre. Explanation: Having too little rain subtracted 20% from 50, leaving 40. Since no fertilizer was used, don't even ask about premium vs. regular, and the yield is unchanged. It is still 40.

Things to make sure of:

1. Prompts the user for the amount of rain.

2. Logs the correct number of asterisks to the console.

3. Is able to detect too much rain.

4. Correctly adjusts yield based on too much rain.

5. Correctly adjusts yield based on too little rain.

6. Prompts the user for the fertilizer (yes or no).

7. Prompts the user for the type of fertilizer (premium or regular) only if they said "yes" for using fertilizer.

8. Adjusts the yield if fertilizer was used. (You will receive this point if yield is increased at all when the user says yes but not when they say no. You will still get this point even if you don't get premium vs. regular working correctly.)

9. Correctly adjusts yield for all fertilizer options in combination with all rain options.

10. Logs final yield result to the console.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!