<!-- Built-In Functions for Apps --> <script type="text/javascript"> var localStoragePrefix = "stock-trading-app";
// save to localstorage function saveLocal(data) { localStorage.setItem(localStoragePrefix, JSON.stringify(data)); }
// load from localstorage function loadLocal() { var data = localStorage.getItem(localStoragePrefix); if (data) { return JSON.parse(data); } }
// Generate random stock prices function generateStockPrices(numDays, minPrice, maxPrice) { var prices = []; for (var i = 0; i < numDays; i++) { var price = Math.floor(Math.random() * (maxPrice - minPrice + 1) + minPrice); prices.push(price); } return prices; }
// Calculate total portfolio value function calculatePortfolioValue(stocks, prices) { var totalValue = 0; for (var i = 0; i < stocks.length; i++) { var stock = stocks[i]; var price = prices[i]; totalValue += stock * price; } return totalValue; }
// Buy stocks function buyStocks(stockIndex, stockPrice, stocks, cash) { var quantity = parseInt(prompt("How many stocks do you want to buy?")); if (isNaN(quantity) || quantity <= 0) { alert("Invalid quantity. Please try again."); return; } var totalPrice = stockPrice * quantity; if (totalPrice > cash) { alert("You don't have enough cash to buy " + quantity + " stocks."); return; } stocks[stockIndex] += quantity; cash -= totalPrice; var portfolioValue = calculatePortfolioValue(stocks, stockPrices); saveLocal({ stocks: stocks, cash: cash, portfolioValue: portfolioValue }); renderPortfolio(stocks, stockPrices, cash); }
// Sell stocks function sellStocks(stockIndex, stockPrice, stocks, cash) { var quantity = parseInt(prompt("How many stocks do you want to sell?")); if (isNaN(quantity) || quantity <= 0) { alert("Invalid quantity. Please try again."); return; } if (quantity > stocks[stockIndex]) { alert("You don't have enough stocks to sell " + quantity + " stocks."); return; } var totalPrice = stockPrice * quantity; stocks[stockIndex] -= quantity; cash += totalPrice; var portfolioValue = calculatePortfolioValue(stocks, stockPrices); saveLocal({ stocks: stocks, cash: cash, portfolioValue: portfolioValue }); renderPortfolio(stocks, stockPrices, cash); }
// Render portfolio table function renderPortfolio(stocks, stockPrices, cash) { var tableHTML = '<table class="table table-striped">'; tableHTML += '<thead>'; tableHTML += '<tr>'; tableHTML += '<th>Stock</th>'; tableHTML += '<th>Price</th>'; tableHTML += '<th>Quantity</th>'; tableHTML += '<th>Value</th>'; tableHTML += '</tr>'; tableHTML += '</thead>'; tableHTML += '<tbody>'; for (var i = 0; i < stocks.length; i++) { var stock = stocks[i]; var price = stockPrices[i]; var value = stock * price; tableHTML += '<tr>'; tableHTML += '<td>Stock ' + (i + 1) + '</td>'; tableHTML += '<td>$' + price + '</td>'; tableHTML += '<td>' + stock + '</td>'; tableHTML += '<td>$' + value + '</td>'; tableHTML += '</tr>'; } tableHTML += '</tbody>'; tableHTML += '</table>';
Calculator Tools allows you to instantly create and generate any simple one page web app for
free and immediately have it online to use and share. This means anything! Mini apps,
calculators, trackers, tools, games, puzzles, screensavers... anything you can think of that the
AI can handle.
The AI uses Javacript, HTML, and CSS programming to code your app up in moments. This currently
uses GPT-4 the latest and most powerful version of the OpenAI GPT language model.
What Do You Mean Make An App?
Have you ever just wanted a simple app but didn't want to learn programming or pay someone to
make it for you? Calculator Tools is the solution! Just type in your prompt and the AI will
generate a simple app for you in seconds. You can then customize it to your liking and share it
with your friends.
AI has become so powerful it is that simple these days.
Does This Use ChatGPT?
It uses GPT-4 which is the most powerful model for ChatGPT.
Calculator Tools does not remember things from prompt to prompt, each image is a unique image
that does not reference any of the images or prompts previously supplied.