Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 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. x=<input type="number" id="c"><br>
  38. <input type="button" value="Wykonaj obliczenia" id="przycisk1" onlick="oblicz1()"><br>
  39. Wynik: <br>
  40. <p id="wynik1"></p><br>
  41. </form>
  42. </body>
  43. <script>
  44. function oblicz1() {
  45. var wynik1=document.getElementById("wynik1");
  46. var a=document.getElementById("a");
  47. var b=document.getElementById("b");
  48. var c=document.getElementById("c");
  49. var x=document.getElementById("x");
  50. wynik1.innerHTML=(a.value*Math.pow(x.value,2)+c.value);
  51.  
  52. }
  53. function oblicz() {
  54. var wynik=document.getElementById("wynik");
  55. var kwota=document.getElementById("kwota");
  56. var zczego=document.getElementById("z");
  57. var naco=document.getElementById("na");
  58. if (kwota.value.length == 0 || kwota.value < 0) {
  59. wynik.innerHTML="Kwota nie może być pusta";
  60. return;
  61. }
  62. if (na.value==z.value){
  63. wynik.innerHTML="Waluty nie mogą być takie same";
  64. return;
  65. }
  66. var obliczone=parseInt(kwota.value);
  67.  
  68. switch (z.value) {
  69. case "EUR":
  70. if (na.value=="USD") {
  71. obliczone=kwota.value*1.25}
  72. else {
  73. obliczone=kwota.value*4.35
  74. }
  75. break;
  76. case "PLN":
  77. if (na.value=="USD"){
  78. obliczone=kwota.value*4.1} else
  79. {
  80. obliczone=kwota.value*4.35
  81. }
  82. break;
  83. case "USD":
  84. if (na.value=="PLN"){
  85. obliczone=kwota.value*4.1}
  86. else
  87. {
  88. obliczone=kwota.value*0.75
  89. } break;
  90. } wynik.innerHTML = obliczone;
  91. }
  92.  
  93. </script>
  94. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement