-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4191581
Showing
4 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Currency Converter</title> | ||
<link rel="stylesheet" href="styles.css" /> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Currency Converter</h1> | ||
<form id="converter-form"> | ||
<label for="conversion-type">Choose conversion type:</label> | ||
<select id="conversion-type"> | ||
<option value="1">USD to EUR</option> | ||
<option value="2">USD to GBP</option> | ||
<option value="3">EUR to USD</option> | ||
<option value="4">EUR to GBP</option> | ||
<option value="5">GBP to USD</option> | ||
<option value="6">GBP to EUR</option> | ||
<option value="7">USD to INR</option> | ||
</select> | ||
<label for="amount">Enter amount to convert:</label> | ||
<input type="number" id="amount" step="0.01" required /> | ||
<button type="button" onclick="convertCurrency()">Convert</button> | ||
<div class="result" id="result"></div> | ||
</form> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |