Advertisement
Guest User

Untitled

a guest
Nov 19th, 2023
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Kalkulator (mówię poważnie) </title>
  7. <link rel="stylesheet" href="styleK.css">
  8. </head>
  9. <body>
  10. <header><h1>Kalkulatory</h1></header>
  11. <aside class="left">
  12. <form id="kalkulator">
  13. <div class="bialykwadrat">
  14. <h2>KALKULATOR</h2>
  15. <input type="text" class="wprowadz" id="wprowadzanie" value=""onclick="wprowadzanie()" disabled>
  16. <input type="text" class="wprowadz" id="wynik" onclick="wynik()" disabled>
  17. <div>
  18. <input type="button" id="7" value="7" onclick="klik(7)"/>
  19. <input type="button" id="8" value="8" onclick="klik(8)"/>
  20. <input type="button" id="9" value="9" onclick="klik(9)"/>
  21. <input type="button" style="width: 40px;" id="dziel" value=":" onclick="klik('/')"/>
  22. </div>
  23. <div>
  24. <input type="button" id="4" value="4" onclick="klik(4)"/>
  25. <input type="button" id="5" value="5" onclick="klik(5)"/>
  26. <input type="button" id="6" value="6" onclick="klik(6)"/>
  27. <input type="button" style="width: 40px;" id="mnoz" value="*" onclick="klik('*')"/>
  28. </div>
  29. <div>
  30. <input type="button" id="1" value="1" onclick="klik(1)"/>
  31. <input type="button" id="2" value="2" onclick="klik(2)"/>
  32. <input type="button" id="3" value="3" onclick="klik(3)"/>
  33. <input type="button" style="width: 40px;" id="dodaj" value="+" onclick="klik('+')"/>
  34. </div>
  35. <div>
  36. <input type="button" id="0" value="0" onclick="klik(0)"/>
  37. <input type="button" style="width: 47px;" id="rowna" value="=" onclick="rownasie()"/>
  38. <input type="button" style="width: 40px;" id="minus" value="-" onclick="klik('-')"/>
  39. </div>
  40. <div>
  41. <input type="button" style="width: 21.42px;" id="przeciwna" value="-/+" onclick="przeciwnaL()"/>
  42. <input type="button" style="width: 21.42px;" id="nawiasL" value="(" onclick="klik('(')"/>
  43. <input type="button" style="width: 21.42px;" id="nawiasP" value=")" onclick="klik(')')"/>
  44. <input type="button" style="width: 40px;" id="potenga" value="^" onclick="klik('**')"/>
  45. </div>
  46. <div>
  47. <input type="button" style="width: 75px; color: red;" id="czysc" value="C" onclick="czyszczenie()"/>
  48. <input type="button" style="width: 40px; color: red;" id="wroc" value="Back" onclick="wracanie()"/>
  49. </div>
  50. </form>
  51. </div>
  52. </aside>
  53. <aside class="right">
  54. <form id="kalkulatorinz">
  55. <div class="bialykwadrat1">
  56. <h3>KALKULATOR INŻ.</h3>
  57. <input type="text" class="wprowadz" id="wprowadzanieI" onclick="wprowadzanieI()" disabled>
  58. <input type="text" class="wprowadz" id="wynikI" onclick="wynikI()" disabled>
  59. <div>
  60. <input type="button" id="7I" value="7" onclick="klikI()"/>
  61. <input type="button" id="8I" value="8" onclick="klikI()"/>
  62. <input type="button" id="9I" value="9" onclick="klikI()"/>
  63. <input type="button" style="width: 40px;" id="xdokwadratu" value="x&sup2" onclick="xdokwadratuI()"/>
  64. </div>
  65. <div>
  66. <input type="button" id="4I" value="4" onclick="klikI()"/>
  67. <input type="button" id="5I" value="5" onclick="klikI()"/>
  68. <input type="button" id="6I" value="6" onclick="klikI()"/>
  69. <input type="button" style="width: 40px;" id="x" value="x" onclick="xI()"/>
  70. </div>
  71. <div>
  72. <input type="button" id="1I" value="1" onclick="klikI()"/>
  73. <input type="button" id="2I" value="2" onclick="klikI()"/>
  74. <input type="button" id="3I" value="3" onclick="klikI()"/>
  75. <input type="button" style="width: 40px;" id="dodajI" value="+" onclick="dodawanieI()"/>
  76. </div>
  77. <div>
  78. <input type="button" id="0I" value="0" onclick="ty()"/>
  79. <input type="button" style="width: 47px;" id="rownaI" value="=" onclick="rownasieI()"/>
  80. <input type="button" style="width: 40px;" id="minusI" value="-/+" onclick="minusI()"/>
  81. </div>
  82. <div>
  83. <input type="button" style="width: 118px;" id="rozwiaz" value="rozwiąż" onclick="rozwiaz()"/>
  84. </div>
  85. <div>
  86. <input type="button" style="width: 75px; color: red;" id="czyscI" value="C" onclick="czyszczenieI()"/>
  87. <input type="button" style="width: 40px; color: red;" id="wrocI" value="Back" onclick="wracanieI()"/>
  88. </div>
  89. </div>
  90. </form>
  91. </aside>
  92. <footer><p>stronę wykonał Wiktor Naklicki</p></footer>
  93. <script type="text/javascript">
  94. function klik(value){
  95. var aktualna = document.getElementById('wprowadzanie').value;
  96. var nowa = aktualna+value;
  97. document.getElementById('wprowadzanie').value = nowa;
  98. }
  99. function czyszczenie(){
  100. document.getElementById('wprowadzanie').value = null;
  101. }
  102. function wracanie(){
  103. var aktualna = document.getElementById('wprowadzanie').value;
  104. if (aktualna.length > 0) {
  105. var nowa = aktualna.slice(0, -1);
  106. document.getElementById('wprowadzanie').value = nowa;
  107. }
  108. }
  109. function rownasie(){
  110. var wyrazenie = document.getElementById('wprowadzanie').value;
  111. if (wyrazenie.length > 0) {
  112. try {
  113. var wynik = eval(wyrazenie);
  114. if(wynik == Infinity){
  115. document.getElementById('wynik').value = 'Nie dziel przez 0!';
  116. }else{
  117. document.getElementById('wynik').value = wynik;
  118. }
  119. } catch (error) {
  120. document.getElementById('wprowadzanie').value = 'Błąd w obliczeniu';
  121. }
  122. }
  123. }
  124. function przeciwnaL() {
  125. var aktualna = document.getElementById('wprowadzanie').value;
  126. if (aktualna.length > 0) {
  127. var ostatniaLiczba = parseFloat(aktualna);
  128. var nowaLiczba = -1 * ostatniaLiczba;
  129. var nowyCiag;
  130. if (nowaLiczba < 0) {
  131. nowyCiag = "(" + nowaLiczba.toString() + ")";
  132. } else {
  133. nowyCiag = nowaLiczba.toString();
  134. }
  135. nowyCiag = aktualna.slice(0, -ostatniaLiczba.toString().length) + nowyCiag;
  136. document.getElementById('wprowadzanie').value = nowyCiag;
  137. }
  138. }
  139. </script>
  140. </body>
  141. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement