screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [income, setIncome] = useState(400000); const [tax, setTax] = useState(0); const calculateTax = () => { let calculatedTax = 0; if (income <= 300000) { calculatedTax = 0; } else if (income > 300000 && income <= 600000) { calculatedTax = (income - 300000) * 0.05; } else if (income > 600000 && income <= 900000) { calculatedTax = 15000 + (income - 600000) * 0.10; } else if (income > 900000 && income <= 1200000) { calculatedTax = 45000 + (income - 900000) * 0.15; } else if (income > 1200000 && income <= 1500000) { calculatedTax = 90000 + (income - 1200000) * 0.20; } else { calculatedTax = 150000 + (income - 1500000) * 0.30; } setTax(calculatedTax); }; return ( <div className='container'> <h2 className='title'>React Js Tax Calculator</h2> <div className='input-section'> <label className='label'>Income: </label> <input className='income-input' type="number" value={income} onChange={(e) => setIncome(e.target.value)} /> </div> <div className='button-section'> <button className='calculate-button' onClick={calculateTax}>Calculate Tax</button> </div> <div className='result-section'> <p className='tax-info'>Tax to Pay: Rs. {tax.toFixed(2)}</p> </div> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { font-family: Arial, sans-serif; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2); max-width: 600px; margin: 0 auto; text-align: center; } /* Title Styles */ .title { font-size: 24px; color: #333; margin-bottom: 20px; } /* Input Section Styles */ .input-section { margin-bottom: 20px; } .label { display: block; font-size: 16px; color: #555; margin-bottom: 5px; text-align: left; } .income-input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 16px; color: #333; outline: none; box-sizing: border-box; } /* Button Section Styles */ .button-section { margin-bottom: 20px; } .calculate-button { background-color: #007BFF; color: #fff; padding: 10px 20px; border: none; border-radius: 5px; font-size: 18px; cursor: pointer; transition: background-color 0.3s; } .calculate-button:hover { background-color: #0056b3; } /* Result Section Styles */ .result-section { font-size: 20px; } .tax-info { font-weight: bold; color: #007BFF; } </style> </body> </html>