您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
A versatile word problem calculator that handles various equations and unknowns
当前为
// ==UserScript== // @name Comprehensive Word Problem Calculator // @namespace http://tampermonkey.net/ // @version 2.9 // @description A versatile word problem calculator that handles various equations and unknowns // @author Your Name // @match https://easybridge-dashboard-web.savvaseasybridge.com/dashboard/student?ssoLogin=true // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function wordProblemCalculator() { const problem = prompt("Enter a word problem (e.g., '8 divided by 2' or '9 times what equals 81'). You can also type 'div' for division:").toLowerCase(); let result; // Handle equal distribution phrases if (problem.includes("bananas") && problem.includes("to put in") && problem.includes("boxes")) { const numbers = problem.match(/\d+/g); if (numbers && numbers.length >= 2) { const total = parseFloat(numbers[0]); // Total number of bananas const boxes = parseFloat(numbers[1]); // Number of boxes result = total / boxes; // Calculate how many bananas per box } else { alert("Could not find enough numbers."); return; } } // Handle division for "what" else if (problem.includes("times what") || problem.includes("what times") || problem.includes("what equals")) { const numbers = problem.match(/\d+/g); if (numbers && numbers.length === 2) { const num1 = parseFloat(numbers[0]); // The number before "times" const total = parseFloat(numbers[1]); // The number after "equals" result = total / num1; // Solve for "what" } else { alert("Could not find enough numbers."); return; } } // Handle standard operations else { const matches = problem.match(/(\d+)\s*(\w+)\s*(\d+)/); if (matches) { const num1 = parseFloat(matches[1]); const operation = matches[2]; const num2 = parseFloat(matches[3]); switch (operation) { case "plus": case "+": result = num1 + num2; break; case "minus": case "-": result = num1 - num2; break; case "times": case "x": result = num1 * num2; break; case "div": case "divided by": case "/": if (num2 !== 0) { result = num1 / num2; } else { alert("Cannot divide by zero."); return; } break; default: alert("Could not understand the operation."); return; } } else { alert("Could not understand the word problem."); return; } } alert(`The result of the problem is: ${result}`); } // Run the calculator wordProblemCalculator(); })();