Code Monkey home page Code Monkey logo

Comments (1)

dijanacvc avatar dijanacvc commented on July 24, 2024
<title>Random Division Task</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f5f5f5; text-align: center; }
    .task-container {
        background-color: white;
        border: 1px solid #000;
        border-radius: 5px;
        padding: 20px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 50px;
    }

    .task {
        font-size: 24px;
        text-align: center;
        margin-bottom: 15px;
        line-height: 1.5; 
    }

    .task pre {
        margin: 0;
        white-space: pre-wrap;
    }

    .user-input {
        padding: 5px;
        font-size: 20px;
        text-align: center;
        width: 100px;
    }

    .division-symbol {
        font-size: 28px;
        vertical-align: middle;
    }

    .check-button {
        margin-top: 10px;
        background-color: #4CAF50;
        color: white;
        border: none;
        border-radius: 5px;
        padding: 10px 20px;
        cursor: pointer;
    }

    .solution {
        font-size: 20px;
        margin-top: 15px;
    }
    #dividend, #divisor {
font-size: 24px; 

}

.equals-symbol {
font-size: 24px;
}

</style>
Löse die folgende Aufgabe mit der schriftlichen Divisionsmethode:


    <pre>
<span id="dividend"></span> <span class="division-symbol">÷</span> <span id="divisor"></span> <span class="equals-symbol">=</span> 
    </pre>
    </div>
     <div>
        <input class="user-input" type="text" id="userAnswer" placeholder="   ">
    </div>
    <div>
        <button class="check-button" onclick="checkAnswer()">Check</button>
    </div>
    <div class="solution" id="solution"></div>
</div>

<script>
    function generateDivisionTask() {
        let dividend, divisor, answer;
        do {
            dividend = Math.floor(Math.random() * 1000) + 100;
            divisor = Math.floor(Math.random() * 30) + 2;
            answer = dividend / divisor;
        } while (answer % 1 !== 0); 
        return {
            dividend: dividend,
            divisor: divisor,
            answer: answer
        };
    }
  

    const task = generateDivisionTask();
    document.getElementById('dividend').textContent = task.dividend;
    document.getElementById('divisor').textContent = task.divisor;

    function checkAnswer() {
        const userAnswer = document.getElementById('userAnswer').value.replace(/\s/g, ''); 
        const correctAnswer = task.answer;
        const solutionDiv = document.getElementById('solution');

        if (!isNaN(userAnswer) && userAnswer.length > 0) {
            if (parseFloat(userAnswer) === correctAnswer) {
                solutionDiv.textContent = 'Richtig! Die Antwort ist ' + correctAnswer + '.';
                solutionDiv.style.color = 'green';
            } else {
                solutionDiv.textContent = 'Falsch. Versuche es erneut.';
                solutionDiv.style.color = 'red';
            }
        } else {
            solutionDiv.textContent = 'Bitte gib eine gültige Zahl ein.';
            solutionDiv.style.color = 'red';
        }
    }
</script>

from kumon-math-app.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.