Develop a program that inputs one salesperson's items sold for last week, calculates that salesperson's earnings and outputs HTML text that displays that salesperson's earnings.

A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross
sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000,
or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows:
Item Value
1 239.99
2 129.75
3 99.95
4 350.89


Top:
Determine a salesperson’s earnings for last week.
First refinement:
Initialize variables
Input items sold
Calculate and display salesperson’s earnings
Second Refinement:
Initialize gross to zero
While there are still product sales to input
Read number sold of product
Determine the product value and add it to the gross
Calculate salesperson’s earnings
Display salesperson’s earnings

```
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <!-- ex14_13.html -->
3 <HTML>
4 <HEAD>
5 <TITLE>Solution: 14.13</TITLE>
6
7 <SCRIPT LANGUAGE = "JavaScript">
8 var gross = 0.0, earnings, product = 0, number;
9 var input;
10
11 while ( product < 4 ) {
12 ++product;
13
14 // read number from user as a string
15 input = window.prompt( "Enter number sold of product #" + product + ":", "0" );
16
17 // convert numbers from a string to an integer
18 number = parseInt( input );
19
20 if ( product == 1 )
21 gross += number * 239.99;
22 else if ( product == 2 )
23 gross += number * 129.75;
24 else if ( product == 3 )
25 gross += number * 99.95;
26 else if ( product == 4 )
27 gross += number * 350.89;
28 }
29
30 earnings = .09 * gross + 200;
31
32 document.writeln( "<P>This salesperson earned " + earnings + " this week" );
33 </SCRIPT>
34 </HEAD>
35
36 <BODY>
37 <P>Click Refresh (or Reload) to run this script again.
38 </BODY>
39 </HTML>
```

Computer Science & Information Technology

You might also like to view...

The "stored programming" concept developed by John von Neumann states that any program can be written by using only sequence, selection, and repetition structures.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The ________ element is used with the object element to set its properties

A) classid B) value C) name D) param

Computer Science & Information Technology

Case 1Matthew has assigned a project to a new designer at XYZ Corporation.  Matthew is working with the new designer to familiarize her with the contents of the dialog box shown below.Referring to the figure above, which list should be chosen to display all HTML elements and choose the one for which they wish to create a style rule?

A. Define in B. Selector C. URL D. list-style-type

Computer Science & Information Technology

The purpose of a Quick Table is to create a placeholder when creating a new table in a document.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology