Version 1.0.0 (2025-01-02): Material ZPG (2017)
This commit is contained in:
parent
60ab7904d1
commit
69afb4b6cf
26 changed files with 724 additions and 5 deletions
124
6_Software/UebungBinär/DezHex.html
Normal file
124
6_Software/UebungBinär/DezHex.html
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Übung zum Dualsystem</title>
|
||||
</head>
|
||||
|
||||
|
||||
<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000" onLoad="window.innerHeight=300;window.innerWidth=400">
|
||||
|
||||
<h1>Umrechnung von<br> Dezimal- in Hex-Zahlen</h1>
|
||||
<hr noshade size=1><br>
|
||||
<form name=Formular>
|
||||
<script language="javascript">
|
||||
<!--
|
||||
|
||||
function WertHolen(Name) {
|
||||
var Wert = 0;
|
||||
if(document.cookie) {
|
||||
var Wertstart=document.cookie.indexOf(Name+"=");
|
||||
if (Wertstart == -1)
|
||||
Wert = 0
|
||||
else
|
||||
{
|
||||
Cooki = document.cookie.substring(Wertstart+Name.length+1,document.cookie.length);
|
||||
var Wertende = Cooki.indexOf(";");
|
||||
if (Wertende == -1)
|
||||
Wertende = Cooki.length;
|
||||
Wert = parseInt( Cooki.substring(0,Wertende));
|
||||
}
|
||||
}
|
||||
return Wert;
|
||||
}
|
||||
|
||||
function WertSetzen(Bezeichner, Wert, Verfall) {
|
||||
var jetzt = new Date();
|
||||
var Auszeit = new Date(jetzt.getTime() + Verfall);
|
||||
document.cookie = Bezeichner+"="+Wert+"; expires="+Auszeit.toGMTString()+";";
|
||||
}
|
||||
|
||||
|
||||
function NeueZahl(Richtige)
|
||||
{
|
||||
if(richtige<3)
|
||||
{
|
||||
zahl = Math.round(Math.random()*15)
|
||||
stufe = "Übung macht den Meister...";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(richtige<6)
|
||||
{
|
||||
zahl = Math.round(Math.random()*240)+16;
|
||||
stufe = "So langsam hast Du es raus...";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(richtige<8)
|
||||
{
|
||||
zahl = Math.round(Math.random()*(256*15-1))+255;
|
||||
stufe = "Jetzt die schwierigen Probleme...";
|
||||
}
|
||||
else
|
||||
{
|
||||
zahl = Math.round(Math.random()*(256*16*15-1))+256*16;
|
||||
stufe = "Du kannst es perfekt! Du hast genug geübt. Aber ich habe noch eine Aufgabe, die auch für Dich bestimmt zu schwer ist:" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
document.write("Bisher hattest Du "+richtige+" Richtige.<br>"+stufe+"<br><br>");
|
||||
document.write("Welche Hexadezimalzahl entspricht der Dezimalzahl "+zahl+"?<br><br>");
|
||||
document.write(" <input type=Text name=DualZahl onChange=zahlKorrekt() value='' size=16 maxlength=16> ");
|
||||
document.write(" <input type=Button value=Überprüfen onClick=zahlKorrekt()>");
|
||||
document.Formular.DualZahl.focus();
|
||||
}
|
||||
|
||||
richtige = WertHolen("DezHexR")
|
||||
NeueZahl(richtige);
|
||||
|
||||
function makeDual(i)
|
||||
{
|
||||
t="";
|
||||
while (i>=1)
|
||||
{
|
||||
r=i%16;
|
||||
if (r<10)
|
||||
t=r+t
|
||||
else
|
||||
{
|
||||
switch(r)
|
||||
{
|
||||
case 10: { t="A"+t; break;}
|
||||
case 11: { t="B"+t; break;}
|
||||
case 12: { t="C"+t; break;}
|
||||
case 13: { t="D"+t; break;}
|
||||
case 14: { t="E"+t; break;}
|
||||
case 15: { t="F"+t; break;}
|
||||
}
|
||||
}
|
||||
i= (i-r)/16;
|
||||
}
|
||||
if (t=="") t="0";
|
||||
return t;
|
||||
}
|
||||
|
||||
function zahlKorrekt()
|
||||
{
|
||||
if (document.Formular.DualZahl.value==makeDual(zahl))
|
||||
{
|
||||
richtige= richtige+1;
|
||||
WertSetzen("DezHexR",richtige,1000*60*60*24);
|
||||
alert("Super! Das war richtig! Schon "+richtige+" Richtige");
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("Schade, leider falsch!\nRichtig wäre "+ makeDual(zahl)+" gewesen.");
|
||||
}
|
||||
window.open("DezHex.html","_self");
|
||||
|
||||
}
|
||||
|
||||
|
||||
-->
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue