|
Java Tschenrechner
Wurzelziehen,Klammerrechnungen usw. kein Problem damit.
<div style="background-color: rgb(0, 0, 0);"><br /><br />
<div style="text-align: center;"><span style="font-size: large;"><strong><span style="color: rgb(255, 0, 0);">Taschenrechner</span></strong></span><br /><br />
<center>
<script type='text/javascript'>
<!--
var art;
var z = -1;
var zahl1;
var zahl2;
var ende=false;
function berechne()
{
try
{
document.taschenrechner.ergebnis.value=eval(document.taschenrechner.ergebnis.value);
ende=true
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function addi()
{
document.taschenrechner.ergebnis.value=document.taschenrechner.ergebnis.value + "+";
}
function subtr()
{
document.taschenrechner.ergebnis.value=document.taschenrechner.ergebnis.value + "-";
}
function multi()
{
document.taschenrechner.ergebnis.value=document.taschenrechner.ergebnis.value + "*";
}
function divis()
{
document.taschenrechner.ergebnis.value=document.taschenrechner.ergebnis.value + "/";
}
function wurz()
{
try
{
document.taschenrechner.ergebnis.value =Math.sqrt(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function betr()
{
try
{
document.taschenrechner.ergebnis.value =Math.abs(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function sinus()
{
try
{
document.taschenrechner.ergebnis.value =Math.sin(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function cosinus()
{
try
{
document.taschenrechner.ergebnis.value =Math.cos(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function tangens()
{
try
{
document.taschenrechner.ergebnis.value =Math.tan(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function arctangens()
{
try
{
document.taschenrechner.ergebnis.value =Math.atan(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function arcsinus()
{
try
{
document.taschenrechner.ergebnis.value =Math.asin(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function arccosinus()
{
try
{
document.taschenrechner.ergebnis.value =Math.acos(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function logarithmus()
{
try
{
document.taschenrechner.ergebnis.value =Math.log(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function expo()
{
try
{
document.taschenrechner.ergebnis.value =Math.exp(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function ln()
{
try
{
document.taschenrechner.ergebnis.value =Math.LN2
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function rund()
{
try
{
document.taschenrechner.ergebnis.value =Math.round(eval(document.taschenrechner.ergebnis.value));
ende=true;
}
catch (e)
{
alert("Fehlerhafte Eingabe");
}
}
function lösche()
{
ende = false;
document.taschenrechner.ergebnis.value="0";
}
function save(number)
{
eingabe = document.taschenrechner.ergebnis.value;
if(number=="pi")
{
number=Math.PI;
}
if((eingabe==0)||(ende))
{
eingabe = number;
ende=false;
}
else
{
eingabe=eingabe+number;
}
document.taschenrechner.ergebnis.value = eingabe;
}
//-->
</script>
<style type="text/css">
.tr_button {
width:50px;
text-align:center;
font-family:Comic,System;
font-size:100%;
}
</style>
<form action="" name="taschenrechner" id="taschenrechner">
<table align="center" border="5" cellpadding="10" cellspacing="0" width="190" bgcolor="#FF0000">
<tr>
<td align="right"><input type="text" name="ergebnis" size="30" maxlength="100" value="0" align="right" /></td>
</tr>
<tr>
<td align="center"><table border="5" cellspacing="2" cellpadding="0">
<tr>
<td><input type="button" class="tr_button" width="50" name="eins" value="1" onclick="save(1)" /></td>
<td><input type="button" class="tr_button" width="50" name="zwei" value="2" onclick="save(2)" /></td>
<td><input type="button" class="tr_button" width="50" name="drei" value="3" onclick="save(3)" /></td>
<td><input type="button" class="tr_button" width="50" name="vier" value="4" onclick="save(4)" /></td>
</tr>
<tr>
<td><input type="button" class="tr_button" width="50" name="fünf" value="5" onclick="save(5)" /></td>
<td><input type="button" class="tr_button" width="50" name="sechs" value="6" onclick="save(6)" /></td>
<td><input type="button" class="tr_button" width="50" name="sieben" value="7" onclick="save(7)" /></td>
<td><input type="button" class="tr_button" width="50" name="acht" value="8" onclick="save(8)" /></td>
</tr>
<tr>
<td><input type="button" class="tr_button" name="neun" value="9" onclick="save(9)" /></td>
<td><input type="button" class="tr_button" name="null" value="0" onclick="save(0)" /></td>
<td><input type="button" class="tr_button" name="komma" value="." onclick="save('.')" /></td>
<td><input type="button" class="tr_button" name="runde" value="rund" onclick="rund()" /></td>
</tr>
<tr>
<td><input type="button" class="tr_button" name="plus" value="+" onclick="addi()" /></td>
<td><input type="button" class="tr_button" name="minus" value="-" onclick="subtr()" /></td>
<td><input type="button" class="tr_button" name="mal" value="*" onclick="multi()" /></td>
<td><input type="button" class="tr_button" name="durch" value="/" onclick="divis()" /></td>
</tr>
<tr>
<td><input type="button" class="tr_button" name="pi" value="PI" onclick="save('pi')" /></td>
<td><input type="button" class="tr_button" name="wurzel" value="Wu" onclick="wurz()" /></td>
<td><input type="button" class="tr_button" name="hoch" value="ln" onclick="ln()" /></td>
<td><input type="button" class="tr_button" name="betrag" value="| |" onclick="betr()" /></td>
</tr>
<tr>
<td><input type="button" class="tr_button" name="kauf" value="(" onclick="save('(')" /></td>
<td><input type="button" class="tr_button" name="kzu" value=")" onclick="save(')')" /></td>
<td><input type="button" class="tr_button" name="loga" value="log" onclick="logarithmus()" /></td>
<td><input type="button" class="tr_button" name="expo" value="exp" onclick="expo()" /></td>
</tr>
<tr>
<td><input type="button" class="tr_button" name="sin" value="sin" onclick="sinus()" /></td>
<td><input type="button" class="tr_button" name="cos" value="cos" onclick="cosinus()" /></td>
<td><input type="button" class="tr_button" name="tan" value="tan" onclick="tangens()" /></td>
<td><input type="button" class="tr_button" name="atan" value="atan" onclick="arctangens()" /></td>
</tr>
<tr>
<td><input type="button" class="tr_button" name="asin" value="asin" onclick="arcsinus()" /></td>
<td><input type="button" class="tr_button" name="acos" value="acos" onclick="arccosinus()" /></td>
<td><input type="button" class="tr_button" name="del" value="C" onclick="lösche()" /></td>
<td><input type="button" class="tr_button" name="istgleich" value="=" onclick="berechne()" /></td>
</tr>
</table></td>
</tr>
</table>
</form>
<br />
</center><br /><br /><br /></div>
</div>
|