Create a web page with the heading CIS 114 Homework 6 - Objects.

The contents of this page should be a list of links referring to Parts 1-3 discussed below. Label the links, Part1, and Part2. Include a short description for each part in each part's page.

Part 1:

Create a webpage that contains a script that has a function that uses Math.round, Math.sqrt, Math.floor, toFixed() etc. to obtain the following:

  • round the floating-point number to the nearest integer
  • calculate the square root of the floating-point number and round it to an integer
  • round the floating-point number to the nearest tenths position
  • round the floating-point number to the nearest hundredths position
  • round the floating-point number to the nearest thousandths position

Your page should require the user to enter a floating-point number with AT LEAST 4 decimal positions (no less than that). If the user types any number with less than 4 decimal positions, you should present an error message and do not present any result! Use regex to make sure that the number typed has at least 4 decimal positions!

Your script should display the original floating-point number the user typed, the number rounded to the nearest integer, the square root of the number that is then rounded to an integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth, and the number rounded to the nearest thousandth.

Be sure to use parseFloat() for the inputted number. Use a form input box that the user will use to input and a textarea to display the output. When presenting the output, make sure that there is no error message written - DO NOT PRESENT THE RESULT USING ALERT!!!

When displaying the output, depending on which method you chose, be sure to use toFixed() for displaying the number to the nearest tenths, hundredths, and thousandths positions (just in case you decided to use Math.floor and Math.round for some of the requests for this part). Validate the input and display an error message if the input is invalid. It is acceptable to use jQuery for this problem if you prefer.

Part 2:

Create a webpage that contains a script using a form that allows the user to input several lines of text and a search character and uses the String method charAt to determine the number of occurrences of the search character within the text. Use a form textarea for the text and a form input box for the search character.

If the search character is found within the text, display the number of occurrences of the search character in another input box or a textarea (of course, those should be disabled for users to type anything).

If the search character is not found within the text then display within a new window (using the window.open() method), the message, 'Search character not found in text string!' along with the search character - make sure that the output input box (or textarea) would be cleared if that error message is showing, meaning it would not show any previous result.

Your new window should be a width of 300 pixels, height of 100 pixels, and should not obscure any of the main content already on the page.

Remember that it does not matter if the user types a lowercase letter to search - the match should be done and accepted if the text contains the same letter either in lowercase or uppercase - letter "t" would be found twice in this text "This time"!

For a tip on how to use the charAt() to count the number of occurrences of a character, take a look at example using charAt(): https://hills.ccsf.edu/~cdasilva/cnit133/objex3.html

The only detail is that you should present the count of occurrences in another box and not in the same box where the user typed the sentence!

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.