-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added vice versa functionality in String To Integer Calculator (#1756)
- Loading branch information
Showing
8 changed files
with
87 additions
and
62 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,15 @@ | ||
# <p align="center">Decimal String Calculator</p> | ||
|
||
## Description :- | ||
|
||
This project is a simple web-based calculator that converts strings to integers or decimal numbers and vice-versa. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Screenshots :- | ||
|
||
![image](https://github.com/user-attachments/assets/68aa70ad-a6c9-45dc-b57f-e357c879192c) |
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,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Decimal String Calculator</title> | ||
</head> | ||
|
||
<body> | ||
<div style="display:flex; gap:10px"> | ||
<div class="converter"> | ||
<h2>String To Decimal Calculator</h2> | ||
<textarea id="inputString" placeholder="Enter your string here..."></textarea> | ||
<br> | ||
<button onclick="convertString()">Convert</button> | ||
<br> | ||
<div id="result1"></div> | ||
</div> | ||
<div class="converter"> | ||
<h2>Decimal To String Calculator</h2> | ||
<textarea id="asciiInput" placeholder="Enter your integer separated by comma here..."></textarea> | ||
<br> | ||
<button onclick="convertAsciiToString()">Convert</button> | ||
<br> | ||
<div id="result2"></div> | ||
</div> | ||
</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,24 @@ | ||
function convertString() { | ||
// Get the input string from the textarea | ||
var inputString = document.getElementById('inputString').value; | ||
|
||
// Convert each character to its ASCII value and join with spaces | ||
var asciiValues = Array.from(inputString).map(char => char.charCodeAt(0)).join(' '); | ||
|
||
// Display the result in the result div | ||
document.getElementById('result1').textContent = asciiValues; | ||
} | ||
|
||
function convertAsciiToString() { | ||
// Get the input value | ||
let input = document.getElementById('asciiInput').value; | ||
|
||
// Split the input string into an array of ASCII values | ||
let asciiValues = input.split(',').map(value => parseInt(value.trim())); | ||
|
||
// Convert ASCII values to characters and join them into a string | ||
let result = asciiValues.map(value => String.fromCharCode(value)).join(''); | ||
|
||
// Display the result | ||
document.getElementById('result2').textContent = result; | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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