SOLUTION: Penn State University Computer Science Question


CS170 – Computer Applications for Business
Spring 2022 • Assignment 7
Event Driven Programming
Due Date:
Before 11:59 p.m. on Friday, March 25th, 2022
Accept Until:
Before 11:59 p.m. on Friday, April 1st, 2022
Evaluation:
20 points
Submit to Canvas:
Assignment7.html file
Related Materials:
JavaScript Reference Guide
Need help?
TA office hours and Lab Support Schedule posted in Canvas
YOU ARE ON YOUR HONOR TO COMPLETE THIS ASSIGNMENT WITHOUT ASSISTANCE. You may
use your text and resources available to you through Canvas. You MAY NOT ask any human for
assistance, give assistance to anyone, or use any online tutoring service.
Use only the coding syntax taught to you during classes and recitations. The use of other
coding syntax may result in your work being marked for further review due to possible
unauthorized assistance.
Learning Objectives:
This assignment is designed to practice:
1. Creating an Event Driven JavaScript program.
2. Using Input Elements such as text boxes, buttons, and radio buttons in an event driven
program
3. Implement JavaScript code which will respond to user events.
4. Use of variables: declaration, initialization, modification
5. Use of arithmetic and/or logical operators.
6. Use of comments.
To earn credit for this assignment:
1. You will create a JavaScript program – embedded on an HTML file – according to the
requirements listed on the next pages.
2. Upload and submit a single html file (.html extension) containing the code required.
For your assignment to be graded, please include the following statement: “ On my
honor, I have neither received nor given any unauthorized assistance on this assignment.”
Page 1 of 7
PROBLEM DESCRIPTION
The Insurance Processing program needs to be updated. A GUI (Graphical User Interface) is now
required. Radio buttons and text boxes are needed for input and output purposes. A button will be
used for processing data. Another button will be employed to clear the text boxes and radio
buttons.
You are required to create a webpage to implement the interface required using the JavaScript
programming language. The illustration below displays the format of the GUI screen required.
Note: Choose a background color and a text color of your preference.
Page 2 of 7
As a reminder, the original rules about the logic required are listed below:
The Friendly Insurance company wishes to rewrite their insurance quote request program and
needs a flowchart and pseudocode for their new algorithm. The rules used to process the orders
are listed below:
● Two types of insurance are available for quote, Home and Auto.
o Auto insurance price per year are as follows:
▪ $1000 per year
o Home insurance cost is based on owning or renting
▪ Own: $2000 per year
▪ Rent: $500 per year
● Additional Flood Insurance is also offered at $300 per year for home insurance only. This is
optional.
● A No-Deductible option is also offered at $400 per year for auto only. This is optional.
● A Discount to be subtracted of 3% if you choose to be billed a single time a year or full price when
charged monthly.
Inputs:

Type of Insurance: Home or Auto

Type of Home: Own or Rent

Additional Flood Insurance: Yes or No.

No-Deductible option: Yes or No.

Payment type : Single or Monthly
Outputs:

Total Insurance price (excluding optional items).

Total for the optional items.

Discount amount.

Total amount of the bill (after processing the discount).
Page 3 of 7
Processing:

Process button:
◦ It will read the content of the text boxes.
▪ Example of reading from text box: myVariable = myTextBoxID.value;

It loads the content of the text box whose ID is myTextBoxID into the
variable myVariable.
▪ Notice that the Process button does not need to “read” the radio buttons
since the radio buttons take care of loading the appropriate value to the
variables involved.
◦ It will process the data from the text boxes as well as the data from the radio
buttons and generate the required totals.
▪ The code for the Process button should not include the prompt or alert
functions
◦ It will place the results for the totals on the appropriate output boxes.
▪ Example of writing to a text box: myTextBoxID.value = myVariable;

It writes the content of the variable myVariable to the text box whose
ID is myTextBoxID.

Clear button:
◦ It will reset all variables
▪ The numeric variables should be set 0
▪ The string (text) variables should be set to the empty string.
◦ All the text boxes should be loaded (written to) with the empty string to clear
them of any content.
◦ It will also clear all the radio buttons (see examples on next page).
Page 4 of 7
SAMPLE TRACES THROUGH THE CORRECT ALGORITHM
Inputs:
Insurance Type
Own/Rent
Flood Insurance
No Deductible
Payment Type
Output:
Total Price
Total Optional Items
Total Discount
Total Amount
Sample 1
Sample 2
Sample 3
Auto
Home
Own
Yes
Home
Rent
No
Monthly
Single
2000
300
0
2300
500
0
15
485
Yes
Monthly
1000
400
0
1400
Additional Information:

Be sure to include a comment with your name and section in the part of your HTML
code program.

To simplify the comparison of text data entered by the user, it is often easier to convert this
text to upper case using the notation below.
Syntax example:
textVariable = textVariable.toUpperCase();
(See https://www.w3schools.com/jsref/jsref_toUpperCase.asp for additional example.)
 Syntax example to round up a number to 2 decimals. Just add .toFixed(2) to the variable
name containing the number.
someNumber.toFixed(2)
 You will use several variables in this program.
 It is good practice to store the discount (0.03) in a variable.
 Examples related to radio buttons (these are examples, the name, id and onclick
content should be related to your code):
 Using radio buttons:

 In the example above, the two associated radio buttons, load the appropriate value to the
variable sizeData based on the user’s selection.
Clearing radio buttons:
 The radio buttons in the previous example may be cleared by using the following syntax in a
program:
 large.checked = false;
 small.checked = false;
 Notice that the IDs of the radio buttons are used when clearing a radio button.
Page 5 of 7
Point Values
Screen format with Input Elements (radio buttons, buttons, text boxes)
Variable declarations
Student name inserted as comment in the head section
Process and Clear Buttons with appropriate code
Program execution
5
3
1
6
5
References:







Recitation sessions
Lectures
Fluency textbook Chapter 18
JavaScript Reference Guide
w3schools.com – https://www.w3schools.com/js/default.asp
HTML color names: https://www.w3schools.com/colors/colors_names.asp
Video of a sample run of this assignment: Sample_Video_assignment7.
Addendum
When submitting assignments for CS170, we strongly encourage you to use HTML and
JavaScript elements that were specifically taught in this course. Refer to the learning
objectives listed above and to your notes from lectures and recitations. Going beyond the
scope of this course when developing and submitting your solutions will automatically
result in your submission being FLAGGED as a possible Academic Integrity Violation. Your
submission will then be forwarded to the instructor and/or the course coordinator who will
decide whether further action should be taken. If there is ANY question of an academic
integrity violation, a report will be filed with the University.
The following concepts are among those that ARE NOT covered in this course. DO NOT
include the following HTML/JavaScript/JQuery programming concepts/elements in your
submissions to be graded as they are beyond the scope of this course. Inclusion of these
elements will result in a grade of 0 for the assignment.
variables defined with const
variables defined with let
JavaScript Objects such as:
const person = {
firstName: “John”,
lastName: “Doe”,
age: 50,
eyeColor: “blue”
};
Page 6 of 7
JS arrays of objects
Advanced HTML DOM Document and Element objects and their related
properties and methods: DO NOT USE the elements described on the
W3Schools page: https://www.w3schools.com/js/js_htmldom_document.asp
You are required to write your code using the methods specifically taught in
your class and NOT to use these advanced concepts. Some of these
concepts/methods include:
getELementById Method
inner HTML property
Advanced HTML DOM Events and Event Objects
HTML forms
Any calls using JQuery
Page 7 of 7

Purchase answer to see full
attachment

WE’VE HAD A GOOD SUCCESS RATE ON THIS ASSIGNMENT. PLACE THIS ORDER OR A SIMILAR ORDER AND GET AN AMAZING DISCOUNT