Skip to content

Commit 2f7b405

Browse files
Add files via upload
1 parent f9c8448 commit 2f7b405

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
body{
2+
font-family: Arial, sana-serif;
3+
background-color: hsl(0, 0%, 95%);
4+
}
5+
6+
h1{
7+
color: hsl(223, 100%, 64%);
8+
}
9+
10+
form{
11+
background-color: hsl(0, 0%, 100%);
12+
text-align: center;
13+
max-width: 350px;
14+
margin: auto;
15+
padding: 25px;
16+
border-radius: 10px;
17+
box-shadow: 5px 5px 15px hsl(0, 0%, 0%, 0.3);
18+
}
19+
20+
#textBox{
21+
width: 50%;
22+
font-size: 2em;
23+
border: 2px solid hsl(0, 0%, 0%, 0.8);
24+
border-radius: 4px;
25+
margin-bottom: 15px;
26+
}
27+
28+
label{
29+
font-size: 1.5em;
30+
font-weight: bold;
31+
}
32+
33+
button{
34+
margin-top: 15px;
35+
background-color: hsl(0, 100%, 60%);
36+
color: white;
37+
font-size: 1.5em;
38+
border: none;
39+
padding: 10px 15px;
40+
border-radius: 5px;
41+
cursor: pointer;
42+
}
43+
44+
button:hover{
45+
background-color: hsl(0, 100%, 50%);
46+
}
47+
48+
#result{
49+
font-size: 1.75em;
50+
font-weight: bold;
51+
}
52+
53+
54+
55+
56+
<!DOCTYPE html>
57+
<html lang="en">
58+
<head>
59+
<meta charset="UTF-8">
60+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
61+
<title>VINRADSRI</title>
62+
<link rel="stylesheet" href="style.css">
63+
</head>
64+
<body>
65+
66+
<form>
67+
<h1>Temperature conversion:</h1>
68+
<input type="number" id = "textBox" value = "0"><br>
69+
70+
<input type="radio" id="toFahrenheit" name="unit">
71+
<label for="toFahrenheit">Celsius ➡️ Fahrenheit</label><br>
72+
73+
<input type="radio" id="toCelsius" name="unit">
74+
<label for="toCelsius">Fahrenheit ➡️ Celsius</label><br>
75+
76+
<button type="button" onclick="convert()">submit</button>
77+
<p id="result"></p>
78+
</form>
79+
80+
<script src="index.js"></script>
81+
</body>
82+
</html>
83+
84+
85+
86+
87+
88+
// TEMPERATURE CONVERSION PROGRAM
89+
90+
const textBox = document.getElementById("textBox");
91+
const toFahrenheit = document.getElementById("toFahrenheit");
92+
const toCelsius = document.getElementById("toCelsius");
93+
const result = document.getElementById("result");
94+
let temp;
95+
96+
function convert(){
97+
98+
if(toFahrenheit.checked){
99+
temp = Number(textBox.value);
100+
temp = temp * 9 / 5 +32
101+
result.textContent = temp.toFixed(1) + "°F";
102+
}
103+
else if(toCelsius.checked){
104+
temp = Number(textBox.value);
105+
temp = (temp - 32) * (5/9);
106+
result.textContent = temp.toFixed(1) + "°C";
107+
}
108+
else{
109+
result.textContent = "Select a unit";
110+
}
111+
}
112+

0 commit comments

Comments
 (0)