NeeilCalc

Size
3,209 Kb
Views
34,408

How do I make an neeilcalc?

What is a neeilcalc? How do you make a neeilcalc? This script and codes were developed by Neeilan Selvalingam on 13 September 2022, Tuesday.

NeeilCalc Previews

NeeilCalc - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>neeilCalc</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <head>
<link href='https://fonts.googleapis.com/css?family=Share+Tech+Mono' rel='stylesheet' type='text/css'></head>
<div id="calculator">
<table> <tr> <td colspan="3" id="display"></td> </tr> <tr> <td><button class="btn" onclick="input(1)">1</buttton></td> <td><button class="btn" onclick="input(2)">2</buttton></td> <td><button class="btn" onclick="input(3)">3</buttton></td> </tr> <tr> <td><button class="btn" onclick="input(4)">4</buttton></td> <td><button class="btn" onclick="input(5)">5</buttton></td> <td><button class="btn" onclick="input(6)">6</buttton></td> </tr> <tr> <td><button class="btn" onclick="input(7)">7</buttton></td> <td><button class="btn" onclick="input(8)">8</buttton></td> <td><button class="btn" onclick="input(9)">9</buttton></td> </tr> <tr> <td><button class="btn op" onclick="input('+')">+</buttton></td> <td><button class="btn" onclick="input(0)">0</buttton></td> <td><button class="btn op" onclick="input('-')">-</buttton></td> </tr> <tr> <td><button class="btn op" onclick="input('*')">*</buttton></td> <td><button class="btn op" onclick="input('/')">/</buttton></td> <td><button class="btn op" onclick="input('.')">.</buttton></td> </tr> <tr> <td><button class="btn op" onclick="input('NEG')">	&plusmn;</buttton></td> <td><button class="btn op" onclick="input('C')">CE</buttton></td> <td><button class="btn calc" onclick="input('=')">=</buttton></td> </tr> <tr></tr>
</table>
</div> <script src="js/index.js"></script>
</body>
</html>

NeeilCalc - Script Codes CSS Codes

html,body { height:100%; background: rgb(1,15,22); font-family: Helvetica, Arial;
}
#display { width: 300px; background: rgb(35,182,79); overflow:hidden; color: rgb(22,118,15); padding-right: 5%; font-size: 2.1em; font-family: 'Share Tech Mono', 'Arial'; font-weight: bold; text-align: right; margin-left: -5; border: solid rgb(221,221,221); border-width:15px 25px 20px 25px;
}
table { height: 600px; width: 430px; margin: 5% auto 0% auto; background: rgb(230,230,230); border-radius:5px; box-shadow: 0px 0px 50px 0px rgb(38,57,83);
}
.btn { background: #AEC6CF; width: 45%; height: 75%; border-radius: 70%; color: white; border-style: none; font-size: 1em;
}
.btn:active { width: 44%; height: 74%;
}
.op { background:rgb(103,148,165) ;
}
.calc{ background:rgb(227,128,128) ;
}
.btn:hover { background: #de6868; font-weight: bold;
}
.btn:focus { outline:none;
}
td{ height: 14%; text-align: center; width:30%;
}
table:hover { box-shadow: 0px 0px 120px 0px rgb(48,71,103);
}
table:hover #display { background-color: rgb(52,216,101); color: rgb(34,179,78);
}

NeeilCalc - Script Codes JS Codes

var display="";
var values= [];
function input (value){ if (value==="C"){ clear(); } else if (value==="="){ display = process(); //process() returns final answer } else if (value==="NEG"){ values.push("NEG"); display+="-"; } else{ values.push(value); display+=""+value; } updateDisplay();
}
function process() { joinNums(); joinDecimals(); //***BUG with decimals longer than 1*** FIXED console.log(values); neg(); repeatCatcher(); //if consecutive operations are stringed together, return value of last operation rather than NaN/error multiplyVals(); addVals(); //console.log(values); //max of 8 decimal places return Math.round(values[0]*100000000)/100000000;
}
function neg(){ //call after joining nums and decimals for (var i=0; i<values.length-1; i++){ if (values[i]==="NEG"){ values[i+1]=values[i+1]*(-1); values[i]="$"; } } values = values.filter(filter$);
}
function joinNums(){ //Joins consecutive digits into numbers for (var i=0; i<values.length-1; i++){ if (typeof(values[i])==="number" && typeof(values[i+1])==="number") { values[i+1]=Number(values[i]+""+values[i+1]); values[i]="$"; } } values = values.filter(filter$);
}
function joinDecimals() { //Call after joinNums var divisionFactor=10; for (var i=0; i<values.length-1; i++){ if (values[i]==="."){ var decimalLength = (""+values[i+1]).length; divisionFactor= Math.pow(10,decimalLength); //to account for decimal portions of varying length ex- 0.5 vs 0.55 values[i+1]=values[i-1]+values[i+1]/divisionFactor; values[i]="$"; values[i-1]="$"; } } values = values.filter(filter$);
}
var filter$ = function(val){ return (val!=="$");
}
function multiplyVals() { //Only call after joinNums + joinDecimals for (var i=0; i<values.length-1; i++){ if(values[i]==="/"){ //division values[i]="*"; values[i+1]=(1/values[i+1]); } if (values[i]==="*"){ values[i+1]=values[i+1]*values[i-1]; values[i]="$"; values[i-1]="$"; } // if(values[i]==="/"){ //division // not needde if adjusted before multiplying // values[i+1]=values[i-1]/values[i+1]; // values[i]="$"; // values[i-1]="$"; // } } values = values.filter(filter$);
}
function addVals() { //Call after multiplyVals for (var i=0; i<values.length-1; i++){ if(values[i]==="-"){ //subtraction values[i]="+"; values[i+1]=(-1*values[i+1]); } if (values[i]==="+"){ values[i+1]=values[i+1]+values[i-1]; values[i]="$"; values[i-1]="$"; } } values = values.filter(filter$);
}
function repeatCatcher() { for (var i=0; i<values.length-1; i++){ if (typeof(values[i])!=="number" && typeof(values[i+1])!=="number") { values[i]="$"; } }
}
function clear(){ display=""; values=[];
}
function updateDisplay() { if (display.length>14){ display="..."+display.substring(display.length-15,display.length); } document.getElementById("display").innerHTML=display;
}
NeeilCalc - Script Codes
NeeilCalc - Script Codes
Home Page Home
Developer Neeilan Selvalingam
Username neeilan
Uploaded September 13, 2022
Rating 3
Size 3,209 Kb
Views 34,408
Do you need developer help for NeeilCalc?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Neeilan Selvalingam (neeilan) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!