Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pl">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Kalkulator (mówię poważnie) </title>
- <link rel="stylesheet" href="styleK.css">
- </head>
- <body>
- <header><h1>Kalkulatory</h1></header>
- <aside class="left">
- <form id="kalkulator">
- <div class="bialykwadrat">
- <h2>KALKULATOR</h2>
- <input type="text" class="wprowadz" id="wprowadzanie" value=""onclick="wprowadzanie()" disabled>
- <input type="text" class="wprowadz" id="wynik" onclick="wynik()" disabled>
- <div>
- <input type="button" id="7" value="7" onclick="klik(7)"/>
- <input type="button" id="8" value="8" onclick="klik(8)"/>
- <input type="button" id="9" value="9" onclick="klik(9)"/>
- <input type="button" style="width: 40px;" id="dziel" value=":" onclick="klik('/')"/>
- </div>
- <div>
- <input type="button" id="4" value="4" onclick="klik(4)"/>
- <input type="button" id="5" value="5" onclick="klik(5)"/>
- <input type="button" id="6" value="6" onclick="klik(6)"/>
- <input type="button" style="width: 40px;" id="mnoz" value="*" onclick="klik('*')"/>
- </div>
- <div>
- <input type="button" id="1" value="1" onclick="klik(1)"/>
- <input type="button" id="2" value="2" onclick="klik(2)"/>
- <input type="button" id="3" value="3" onclick="klik(3)"/>
- <input type="button" style="width: 40px;" id="dodaj" value="+" onclick="klik('+')"/>
- </div>
- <div>
- <input type="button" id="0" value="0" onclick="klik(0)"/>
- <input type="button" style="width: 47px;" id="rowna" value="=" onclick="rownasie()"/>
- <input type="button" style="width: 40px;" id="minus" value="-" onclick="klik('-')"/>
- </div>
- <div>
- <input type="button" style="width: 21.42px;" id="przeciwna" value="-/+" onclick="przeciwnaL()"/>
- <input type="button" style="width: 21.42px;" id="nawiasL" value="(" onclick="klik('(')"/>
- <input type="button" style="width: 21.42px;" id="nawiasP" value=")" onclick="klik(')')"/>
- <input type="button" style="width: 40px;" id="potenga" value="^" onclick="klik('**')"/>
- </div>
- <div>
- <input type="button" style="width: 75px; color: red;" id="czysc" value="C" onclick="czyszczenie()"/>
- <input type="button" style="width: 40px; color: red;" id="wroc" value="Back" onclick="wracanie()"/>
- </div>
- </form>
- </div>
- </aside>
- <aside class="right">
- <form id="kalkulatorinz">
- <div class="bialykwadrat1">
- <h3>KALKULATOR INŻ.</h3>
- <input type="text" class="wprowadz" id="wprowadzanieI" onclick="wprowadzanieI()" disabled>
- <input type="text" class="wprowadz" id="wynikI" onclick="wynikI()" disabled>
- <div>
- <input type="button" id="7I" value="7" onclick="klikI()"/>
- <input type="button" id="8I" value="8" onclick="klikI()"/>
- <input type="button" id="9I" value="9" onclick="klikI()"/>
- <input type="button" style="width: 40px;" id="xdokwadratu" value="x²" onclick="xdokwadratuI()"/>
- </div>
- <div>
- <input type="button" id="4I" value="4" onclick="klikI()"/>
- <input type="button" id="5I" value="5" onclick="klikI()"/>
- <input type="button" id="6I" value="6" onclick="klikI()"/>
- <input type="button" style="width: 40px;" id="x" value="x" onclick="xI()"/>
- </div>
- <div>
- <input type="button" id="1I" value="1" onclick="klikI()"/>
- <input type="button" id="2I" value="2" onclick="klikI()"/>
- <input type="button" id="3I" value="3" onclick="klikI()"/>
- <input type="button" style="width: 40px;" id="dodajI" value="+" onclick="dodawanieI()"/>
- </div>
- <div>
- <input type="button" id="0I" value="0" onclick="ty()"/>
- <input type="button" style="width: 47px;" id="rownaI" value="=" onclick="rownasieI()"/>
- <input type="button" style="width: 40px;" id="minusI" value="-/+" onclick="minusI()"/>
- </div>
- <div>
- <input type="button" style="width: 118px;" id="rozwiaz" value="rozwiąż" onclick="rozwiaz()"/>
- </div>
- <div>
- <input type="button" style="width: 75px; color: red;" id="czyscI" value="C" onclick="czyszczenieI()"/>
- <input type="button" style="width: 40px; color: red;" id="wrocI" value="Back" onclick="wracanieI()"/>
- </div>
- </div>
- </form>
- </aside>
- <footer><p>stronę wykonał Wiktor Naklicki</p></footer>
- <script type="text/javascript">
- function klik(value){
- var aktualna = document.getElementById('wprowadzanie').value;
- var nowa = aktualna+value;
- document.getElementById('wprowadzanie').value = nowa;
- }
- function czyszczenie(){
- document.getElementById('wprowadzanie').value = null;
- }
- function wracanie(){
- var aktualna = document.getElementById('wprowadzanie').value;
- if (aktualna.length > 0) {
- var nowa = aktualna.slice(0, -1);
- document.getElementById('wprowadzanie').value = nowa;
- }
- }
- function rownasie(){
- var wyrazenie = document.getElementById('wprowadzanie').value;
- if (wyrazenie.length > 0) {
- try {
- var wynik = eval(wyrazenie);
- if(wynik == Infinity){
- document.getElementById('wynik').value = 'Nie dziel przez 0!';
- }else{
- document.getElementById('wynik').value = wynik;
- }
- } catch (error) {
- document.getElementById('wprowadzanie').value = 'Błąd w obliczeniu';
- }
- }
- }
- function przeciwnaL() {
- var aktualna = document.getElementById('wprowadzanie').value;
- if (aktualna.length > 0) {
- var ostatniaLiczba = parseFloat(aktualna);
- var nowaLiczba = -1 * ostatniaLiczba;
- var nowyCiag;
- if (nowaLiczba < 0) {
- nowyCiag = "(" + nowaLiczba.toString() + ")";
- } else {
- nowyCiag = nowaLiczba.toString();
- }
- nowyCiag = aktualna.slice(0, -ostatniaLiczba.toString().length) + nowyCiag;
- document.getElementById('wprowadzanie').value = nowyCiag;
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement