Skip to content

Commit 12a10e3

Browse files
committed
Working on Chapter 11 exercise 2
1 parent 3869f9f commit 12a10e3

File tree

2 files changed

+77
-9
lines changed

2 files changed

+77
-9
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"liveServer.settings.port": 5501
2+
"liveServer.settings.port": 5502
33
}

ch11exercise2.html

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,89 @@
44
<title>Chapter 11</title>
55
</head>
66
<body>
7-
<h1>Centigrade to Fahrenheit Converter</h1>
7+
<h1>Choose your computer type</h1>
88
<form id="form1" name="form1">
9-
<input type="number" name="centigrade" id="centigrade" />
9+
<h3>Processor Type</h3>
10+
<input type="radio" name="CPUtype" id="amd" value="amd" />
11+
<label for="amd">AMD</label>
12+
<input type="radio" name="CPUtype" id="intel" value="intel" />
13+
<label for="intel">Intel</label>
14+
1015
<br />
11-
<output id="result" name="result" for="centigrade"></output>
16+
<h3>Processor Speed</h3>
17+
<input type="range" max="4.0" min="3.0" step="0.1" name="CPUspeed" id="Cspeed" />
18+
<output id="speedresult" name="speedresult" for="Cspeed"></output>
19+
20+
<h3>Memory</h3>
21+
<select id="ram">
22+
<option value="2">2 GBs</option>
23+
<option value="4" selected>4 GBs</option>
24+
<option value="8">8 GBs</option>
25+
<option value="16">16 GBs</option>
26+
<option value="32">32 GBs</option>
27+
</select>
28+
29+
<h3>SSD size</h3>
30+
<select id="ssd" size="4">
31+
<option value="128">128 GBs</option>
32+
<option selected value="256">256 GBs</option>
33+
<option value="512">512 GBs</option>
34+
<option value="1024">1 TB</option>
35+
</select>
36+
37+
<h3>HDD size</h3>
38+
<select id="hdd" size="4">
39+
<option value="512">512 GBs</option>
40+
<option selected value="1024">1 TB</option>
41+
<option value="2048">2 TBs</option>
42+
<option value="4096">4 TBs</option>
43+
</select>
44+
45+
<h3>GPU type</h3>
46+
<select id="GPUtype">
47+
<option selected value="NVIDIA">NVIDIA</option>
48+
<option value="AMD">AMD</option>
49+
</select>
50+
51+
<h3>GPU standard</h3>
52+
<select id="GPUstandard">
53+
<option selected value="1">1st Tier</option>
54+
<option value="2">2nd Tier</option>
55+
<option value="3">3rd Tier</option>
56+
<option value="4">4th Tier</option>
57+
</select>
58+
59+
<h3>Extras</h3>
60+
<input type="checkbox" name="DVD-Rom" value="DVD-Rom" id="DVD" />
61+
<label for="DVD">DVD-Rom</label>
62+
<input type="checkbox" name="SoundCard" value="SoundCard" id="Sound" />
63+
<label for="Sound">Sound Card</label>
64+
<input type="checkbox" name="Network" value="Network" id="Network" />
65+
<label for="DVD">Network/WiFi Card</label>
66+
67+
<h3>Total: $<span id="total">0.00</span></h3>
68+
1269
</form>
1370
<script>
1471
//exercise 2
72+
var myform = document.form1;
73+
var speedprice = 300, memoryprice = 0, ssdprice = 0, hddprice = 0, gpuprice = 0, extraprice = 0, totalprice = 0;
74+
var cpumultiplier, gpumultiplier;
75+
76+
myform.speedresult.value = 3.5;
1577
function newValue() {
16-
var degCent = document.form1.centigrade.value;
17-
var degFahren = (9.0 / 5) * degCent + 32;
18-
19-
document.form1.result.value = degFahren;
78+
var speedValue = myform.CPUspeed.value;
79+
80+
myform.speedresult.value = speedValue;
81+
var newspeedValue = (speedValue - 2.9) * 5;
82+
speedprice = 100 * newspeedValue;
83+
addup();
84+
}
85+
86+
function addup() {
87+
totalprice = speedprice + memoryprice + ssdprice + hddprice + gpuprice + extraprice;
2088
}
21-
document.form1.addEventListener("input", newValue);
89+
myform.addEventListener("change", newValue);
2290
</script>
2391
</body>
2492
</html>

0 commit comments

Comments
 (0)