File tree Expand file tree Collapse file tree 3 files changed +84
-0
lines changed
Expand file tree Collapse file tree 3 files changed +84
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7+ < title > Calculator</ title >
8+ < link rel ="stylesheet " href ="s.css " />
9+ </ head >
10+ < body >
11+ < div >
12+ < input type ="number " id ="num1 " />
13+ < input type ="number " id ="num2 " />
14+ < br /> < br />
15+ < button onclick ="add() "> ADD</ button >
16+ < button onclick ="subtract() "> SUBTRACT</ button >
17+ < button onclick ="divide() "> DIVIDE</ button >
18+ < button onclick ="multiply() "> MULTIPLY</ button >
19+
20+ < br />
21+ < br />
22+ < span id ="result "> Result:</ span >
23+ </ div >
24+ < script src ="index.js "> </ script >
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+
2+ let result = document . getElementById ( "result" )
3+
4+ function add ( )
5+ {
6+ let num1 = document . getElementById ( "num1" ) . value
7+ let num2 = document . getElementById ( "num2" ) . value
8+ result . textContent = parseInt ( num1 ) + parseInt ( num2 )
9+ }
10+ function subtract ( )
11+ {
12+ let num1 = document . getElementById ( "num1" ) . value
13+ let num2 = document . getElementById ( "num2" ) . value
14+ result . textContent = parseInt ( num1 ) - parseInt ( num2 )
15+ }
16+ function divide ( )
17+ {
18+ let num1 = document . getElementById ( "num1" ) . value
19+ let num2 = document . getElementById ( "num2" ) . value
20+ result . textContent = parseInt ( num1 ) / parseInt ( num2 )
21+ }
22+ function multiply ( )
23+ {
24+ let num1 = document . getElementById ( "num1" ) . value
25+ let num2 = document . getElementById ( "num2" ) . value
26+ result . textContent = parseInt ( num1 ) * parseInt ( num2 )
27+ }
Original file line number Diff line number Diff line change 1+ * { margin : 0 ;
2+ padding : 0 ;}
3+
4+ div {
5+ background-color : rgba (140 , 187 , 225 , 0.604 );
6+ border : 5px solid rgba (1 , 1 , 46 , 0.866 );
7+ width : 500px ;
8+ height : 250px ;
9+
10+
11+ text-align : center;
12+ margin : auto;
13+ margin-top : 100px ;
14+
15+ padding-top : 100px ;
16+
17+ }
18+ button {
19+ padding : 3px ;
20+ border-radius : 5px ;
21+ }
22+ input {
23+ border-radius : 5px ;
24+ width : 70px ;
25+ height : 30px ;
26+ padding : 5px ;
27+ font-size : 20px ;
28+ }
29+ span {
30+ font-size : 30px ;
31+ }
You can’t perform that action at this time.
0 commit comments