Hauptmenü
Durch einen Klick auf einen Button beginnen die Rechenaufgaben:
(+) |
= Additions- |
(- |
= Multiplikations- |
(*) |
= Subtraktions- |
Durch die Veränderung der Schriftgröße im CSS-
Code für den CSS-
input.btn {color: Black; font-
Code für das HTML-
<script language="Javascript">
function zufallszahl1()
{
var Zahl1=Math.random() * 1000;
Zahl1=Math.round(Zahl1);
return(Zahl1);
}
function zufallszahl2()
{
var Zahl2=Math.random() * 1000;
Zahl2=Math.round(Zahl2);
return(Zahl2);
}
function rechnen()
{
var Zahl1=zufallszahl1()
var Zahl2=zufallszahl2()
var antwort=Zahl1 + Zahl2;
var eingabe=window.prompt("Wie lautet die Summe von " + Zahl1 + " plus " + Zahl2 + " ?", "Die Antwort");
{
if (eingabe == antwort)
{
window.alert("Richtig! Die Summe von " + Zahl1 + " und " + Zahl2 + " ist " + antwort + "!");
}
else
{
window.alert("Falsch! " + eingabe + " ist nicht die Summe von " + Zahl1 + " und " + Zahl2 + ", sondern " + antwort + "!" );
}
}
}
function zufallszahl3()
{
var Zahl3=Math.random() * 50;
Zahl3=Math.round(Zahl3);
return(Zahl3);
}
function zufallszahl4()
{
var Zahl4=Math.random() * 50;
Zahl4=Math.round(Zahl4);
return(Zahl4);
}
function multi()
{
var Zahl1=zufallszahl3()
var Zahl2=zufallszahl4()
var antwort2=Zahl1 * Zahl2;
var eingabe2=window.prompt("Wie lautet das Ergebnis von " + Zahl1 + " mal " + Zahl2 + " ?", "Die Antwort");
{
if (eingabe2 == antwort2)
{
window.alert("Richtig! Das Ergebnis von " + Zahl1 + " mal " + Zahl2 + " ist " + antwort2 + "!");
}
else
{
window.alert("Falsch! " + eingabe2 + " ist nicht das Ergebnis von " + Zahl1 + " mal " + Zahl2 + ", sondern " + antwort2 + "!" );
}
}
}
function subi()
{
var Zahl1=zufallszahl1()
var Zahl2=zufallszahl2()
var antwort2=Zahl1 -
var eingabe2=window.prompt("Wie lautet das Ergebnis von " + Zahl1 + " minus " + Zahl2 + " ?", "Die Antwort");
{
if (eingabe2 == antwort2)
{
window.alert("Richtig! Das Ergebnis von " + Zahl1 + " minus " + Zahl2 + " ist " + antwort2 + "!");
}
else
{
window.alert("Falsch! " + eingabe2 + " ist nicht das Ergebnis von " + Zahl1 + " minus " + Zahl2 + ", sondern " + antwort2 + "!" );
}
}
}
</script>
<form>
<input type="button" class="btn" value="(+)" onClick="rechnen()">
<input type="button" class="btn" value="(*)" onClick="multi()">
<input type="button" class="btn" value="(-
</form>