Simplified version of ATM business

Title description: There is 100 yuan in the account. If depositing money, add the amount of money you input and add the amount of money you deposited first, and then a balance prompt box will pop up; if you withdraw money, subtract the amount of money withdrawn, and then pop up a balance prompt box; if the balance is displayed, output the balance ;If you exit, pop up the exit message prompt box

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Assignment 6</title>

</head>

<body>

    <script>

        var balance = 100; //Define the balance

        var num = parseInt(prompt('Please enter the operation you want:\n1. Deposit money\n2. Withdraw money\n3. Display balance\n4. Exit')); //prompt the business to be handled

        if (num == 1) { //Input is 1, handle deposit business

            var balance1 = parseInt(prompt('Please enter the amount you want to deposit:'));

            balance += balance1; //increase balance

            alert('Your current balance is:' + balance);

        } else if (num == 2) { //Input is 2, handle money withdrawal business

            var balance2 = parseInt(prompt('The balance is 100 yuan, please enter the amount you want to withdraw:'));

            balance -= balance2; //Reduce the balance

            alert('Your current balance is:' + balance);

        } else if (num == 3) { //Input is 3, handle balance inquiry business

            alert('Your current balance is:' + balance);

        } else if (num == 4) { //Input is 4, handle refund business

            alert('The card has been withdrawn, please keep it');

        }

    </script>

</body>

</html>

Guess you like

Origin blog.csdn.net/qq_48491815/article/details/125663628