Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. </head>
  6. <body>
  7. <h1>Kalkulator Walut</h1>
  8. <form><br>
  9. Kwota:<input type="number" id="kwota"><br>
  10.  
  11. Przelicznik z:
  12. <select id="z">
  13. <option value="EUR">EUR - Euro</option>
  14. <option value="PLN">PLN - Złotówka</option>
  15. <option value="USD">USD - Dolar</option>
  16. </select>
  17. <br>
  18. Przelicznik na:
  19. <select id="na">
  20. <option value="EUR">EUR - Euro</option>
  21. <option value="PLN">PLN - Złotówki</option>
  22. <option value="USD">USD - Dolar</option>
  23. </select><br>
  24.  
  25. <input type="button" value="Przelicz" id="przycisk" onclick="oblicz()">
  26. </form><br>
  27. <div id="tak">
  28. Wynik:
  29. </div>
  30. <p id="wynik"></p><br>
  31. <h2>Pierwiastki równania</h2><br>
  32. ax2+bx+c=0<br>
  33. <form>
  34. a=<input type="number" id="a"><br>
  35. b=<input type="number" id="b"><br>
  36. c=<input type="number" id="c"><br>
  37. <input type="button" value="Wykonaj obliczenia" id="przycisk1" onclick="oblicz1()"><br>
  38. Wynik: <br>
  39. <p id="wynik1"></p><br>
  40. </form>
  41. </body>
  42. <script>
  43. function oblicz1() {
  44. var wynik1=document.getElementById("wynik1");
  45. var a=document.getElementById("a").value;
  46. var b=document.getElementById("b").value;
  47. var c=document.getElementById("c").value;
  48. wynik1.innerHTML=(a*Math.pow(b,2)+c);
  49.  
  50. }
  51. function oblicz() {
  52. var wynik=document.getElementById("wynik");
  53. var kwota=document.getElementById("kwota");
  54. var zczego=document.getElementById("z");
  55. var naco=document.getElementById("na");
  56. if (kwota.value.length == 0 || kwota.value < 0) {
  57. wynik.innerHTML="Kwota nie może być pusta";
  58. return;
  59. }
  60. if (na.value==z.value){
  61. wynik.innerHTML="Waluty nie mogą być takie same";
  62. return;
  63. }
  64. var obliczone=parseInt(kwota.value);
  65.  
  66. switch (z.value) {
  67. case "EUR":
  68. if (na.value=="USD") {
  69. obliczone=kwota.value*1.25}
  70. else {
  71. obliczone=kwota.value*4.35
  72. }
  73. break;
  74. case "PLN":
  75. if (na.value=="USD"){
  76. obliczone=kwota.value*4.1} else
  77. {
  78. obliczone=kwota.value*4.35
  79. }
  80. break;
  81. case "USD":
  82. if (na.value=="PLN"){
  83. obliczone=kwota.value*4.1}
  84. else
  85. {
  86. obliczone=kwota.value*0.75
  87. } break;
  88. } wynik.innerHTML = obliczone;
  89. }
  90.  
  91. </script>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement