diff --git a/Currency.java b/Currency.java new file mode 100644 index 0000000..3ba9fb3 --- /dev/null +++ b/Currency.java @@ -0,0 +1,69 @@ +import java.util.Scanner; + +public class Currency { + + public static void main(String[] args) { + + final double USD_TO_EUR = 0.92; + final double USD_TO_GBP = 0.76; + final double EUR_TO_USD = 1.09; + final double EUR_TO_GBP = 0.83; + final double GBP_TO_USD = 1.32; + final double GBP_TO_EUR = 1.20; + final double USD_TO_INR = 83.23; + + Scanner scanner = new Scanner(System.in); + + System.out.println("Currency Converter"); + System.out.println("1. USD to EUR"); + System.out.println("2. USD to GBP"); + System.out.println("3. EUR to USD"); + System.out.println("4. EUR to GBP"); + System.out.println("5. GBP to USD"); + System.out.println("6. GBP to EUR"); + System.out.println("7. USD to INR"); + System.out.print("Choose conversion type (1-7): "); + int choice = scanner.nextInt(); + + System.out.print("Enter amount to convert: "); + double amount = scanner.nextDouble(); + + double result = 0; + + switch (choice) { + case 1: + result = amount * USD_TO_EUR; + System.out.printf("%.2f USD is %.2f EUR\n", amount, result); + break; + case 2: + result = amount * USD_TO_GBP; + System.out.printf("%.2f USD is %.2f GBP\n", amount, result); + break; + case 3: + result = amount * EUR_TO_USD; + System.out.printf("%.2f EUR is %.2f USD\n", amount, result); + break; + case 4: + result = amount * EUR_TO_GBP; + System.out.printf("%.2f EUR is %.2f GBP\n", amount, result); + break; + case 5: + result = amount * GBP_TO_USD; + System.out.printf("%.2f GBP is %.2f USD\n", amount, result); + break; + case 6: + result = amount * GBP_TO_EUR; + System.out.printf("%.2f GBP is %.2f EUR\n", amount, result); + break; + case 7: + result = amount * USD_TO_INR; + System.out.printf("%.2f USD is %.2f INR\n", amount, result); + break; + default: + System.out.println("Invalid choice."); + break; + } + + scanner.close(); + } +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..22910d6 --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ + + + + + + Currency Converter + + + +
+

Currency Converter

+
+ + + + + +
+
+
+ + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..70ffb25 --- /dev/null +++ b/script.js @@ -0,0 +1,50 @@ +function convertCurrency() { + const USD_TO_EUR = 0.92; + const USD_TO_GBP = 0.76; + const EUR_TO_USD = 1.09; + const EUR_TO_GBP = 0.83; + const GBP_TO_USD = 1.32; + const GBP_TO_EUR = 1.2; + const USD_TO_INR = 83.23; + + const conversionType = document.getElementById("conversion-type").value; + const amount = parseFloat(document.getElementById("amount").value); + let result = 0; + let resultText = ""; + + switch (conversionType) { + case "1": + result = amount * USD_TO_EUR; + resultText = `${amount} USD is ${result.toFixed(2)} EUR`; + break; + case "2": + result = amount * USD_TO_GBP; + resultText = `${amount} USD is ${result.toFixed(2)} GBP`; + break; + case "3": + result = amount * EUR_TO_USD; + resultText = `${amount} EUR is ${result.toFixed(2)} USD`; + break; + case "4": + result = amount * EUR_TO_GBP; + resultText = `${amount} EUR is ${result.toFixed(2)} GBP`; + break; + case "5": + result = amount * GBP_TO_USD; + resultText = `${amount} GBP is ${result.toFixed(2)} USD`; + break; + case "6": + result = amount * GBP_TO_EUR; + resultText = `${amount} GBP is ${result.toFixed(2)} EUR`; + break; + case "7": + result = amount * USD_TO_INR; + resultText = `${amount} USD is ${result.toFixed(2)} INR`; + break; + default: + resultText = "Invalid choice."; + break; + } + + document.getElementById("result").innerText = resultText; +} diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..5ba604b --- /dev/null +++ b/styles.css @@ -0,0 +1,144 @@ +body { + font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; + background: linear-gradient(to right, #a2c2e4, #f5f5f5); + color: #333; + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; +} + +.container { + text-align: center; +} + +h1 { + color: #2c3e50; + font-size: 2.5em; + margin-bottom: 20px; + font-weight: 700; + animation: fadeIn 1s ease-out; +} + +form { + background: #ffffff; + padding: 30px; + border-radius: 15px; + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); + max-width: 500px; + width: 100%; + display: flex; + flex-direction: column; + justify-content: space-between; + height: 400px; + animation: slideIn 1s ease-out; +} + +form:hover { + transform: scale(1.02); + box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3); +} + +.form-title { + margin-bottom: 20px; +} + +label { + display: block; + margin: 15px 15px; + font-weight: 630; + font-size: 1.1em; +} + +select, +input[type="number"] { + width: calc(100% - 24px); + padding: 12px; + margin: 5px 0 15px; + border: 2px solid #ddd; + border-radius: 8px; + font-size: 16px; + transition: border-color 0.3s ease; +} + +select:focus, +input[type="number"]:focus { + border-color: #4a90e2; + outline: none; +} + +button { + background: #4a90e2; + color: #fff; + border: none; + border-radius: 8px; + padding: 12px 25px; + font-size: 18px; + cursor: pointer; + transition: background 0.3s ease, transform 0.3s ease; + animation: bounceIn 1s ease-out; +} + +button:hover { + background: #357abd; + transform: scale(1.05); +} + +.result { + font-style: bold; + font-size: 1.2em; + font-weight: 700; + color: #333; + margin-top: 20px; + animation: fadeInUp 1s ease-out; +} + +@keyframes fadeIn { + from { + opacity: 0; + transform: translateY(-20px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes slideIn { + from { + opacity: 0; + transform: translateY(-30px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes bounceIn { + from { + opacity: 0; + transform: scale(0.9); + } + 50% { + opacity: 1; + transform: scale(1.05); + } + to { + opacity: 1; + transform: scale(1); + } +} + +@keyframes fadeInUp { + from { + opacity: 0; + transform: translateY(20px); + } + to { + opacity: 1; + transform: translateY(0); + } +}