Проблема состоит в том, что у меня есть платформа для работы, в которой мне нужно вычислить и расчет вручную, настолько утомительна, поэтому я создал Код в Python, который работает хорошо, как я хочу, но я хочу показать его графически, поэтому я изменил код на JavaScript, чтобы показать в таблице, в отличие от списков Python, но это создает результат для 11 рядов, но мне нужно минимум 50 раундов
strong. > Другими словами, мне нужно расчет, который покажет мне, что добавить дальше от первого до 50 в форме таблицы. < /p>
Я попробовал ниже html -код и хотел получить результат кода Python, который в конце концов я суммирует форму через HTML. < /p>
Код: Выделить всё
Calculator
body {
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
}
.input {
background-color: #f7f7f7;
padding: 2em;
border: 1px solid #ddd;
box-shadow: 0 0 10px rgba(0, 0, 0, 1);
}
.output {
background-color: #f7f7f7;
padding: 2em;
border: 1px solid #ddd;
box-shadow: 0 0 10px rgba(0, 0, 0, 1);
}
Код: Выделить всё
Calculator
Calculate
Round no.
Amount
Total in
Status
Total out
Profit
< /code>
function CanculateInningsandprofit () {< /p>
const amountForCalculation = parseInt(document.querySelector('input[type="number"]').value);
const amount = 20;
const addingAmount = 20;
let totalInF = 0;
let roundsNo = [];
let amountsIn = [];
let totalsIn = [];
let profits = [];
let round = 1;
let addRow = true;
while (addRow) {
let maxProfitIn = amount * 11.4;
let totalIn = totalInF + amount;
let profit = maxProfitIn - totalIn;
if (totalIn > amountForCalculation) {
addRow = false;
} else {
totalsIn.push(totalIn);
profits.push(profit);
amountsIn.push(amount);
totalInF = totalIn;
if (totalIn < maxProfitIn) {
// do nothing
} else {
amount += addingAmount;
}
round++;
}
}
roundsNo = Array.from({length: totalsIn.length}, (_, i) => i + 1);
const outputTableBody = document.getElementById('output-table-body');
outputTableBody.innerHTML = '';
for (let i = 0; i < roundsNo.length; i++) {
const row = document.createElement('tr');
row.innerHTML = `
${roundsNo[i]}
${amountsIn[i]}
${totalsIn[i]}
${profits[i]}
`;
outputTableBody.appendChild(row);
}
< /code>
} < /p>
< /code>
rounds_no = [] < /p>
namounts_in = [] < /p>
totals_in = []
Подробнее здесь: [url]https://stackoverflow.com/questions/79383346/creating-table-using-javascript-with-respective-increase-but-it-only-creates-for[/url]