Skip to content

done #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

done #76

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions WebDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ Remember, the deadline for this week's task is June 7th, 2022, at 23:59.
<!-- - Your Name - [Repo Name](Link) [Site](Site Link) -->

<!-- - Sanyu Daver - [Tic Tac](https://github.com/sanyud/TicTac) [Site](www.copsiitbhu.co.in) -->

Ankit Kansal - [calculator](https://github.com/ankit-kansal/CSOC22-Week1)[Site](www.copsiitbhu.co.in)
65 changes: 65 additions & 0 deletions calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<html>
<head>
<title>calculator</title>
<link rel="stylesheet" href="/styles.css">
</head>

<body>
<center>
<header>Calculator</header>
<table class="center">
<tr>
<td colspan="3"><input type="text" id="scrn"></td>
<td><input type="button" value="=" onclick="calculate()" id="btn" /></td>
<td><input type="button" value="AC" onclick="clearAll()" id="btn" /></td>
</tr>
<tr>
<td><input type="button" value="7" onclick="display('7')" id="btn" /></td>
<td><input type="button" value="8" onclick="display('8')" id="btn" /></td>
<td><input type="button" value="9" onclick="display('9')" id="btn" /></td>
<td><input type="button" value="+" onclick="display('+')" id="btn" /></td>
<td><input type="button" value="*" onclick="display('*')" id="btn" /></td>
</tr>
<tr>
<td><input type="button" value="4" onclick="display('4')" id="btn" /></td>
<td><input type="button" value="5" onclick="display('5')" id="btn" /></td>
<td><input type="button" value="6" onclick="display('6')" id="btn" /></td>
<td><input type="button" value="-" onclick="display('-')" id="btn" /></td>
<td><input type="button" value="/" onclick="display('/')" id="btn" /></td>
</tr>
<tr>
<td><input type="button" value="1" onclick="display('1')" id="btn" /></td>
<td><input type="button" value="2" onclick="display('2')" id="btn" /></td>
<td><input type="button" value="3" onclick="display('3')" id="btn" /></td>
<td><input type="button" value="C" onclick="cut()" id="btn" /></td>
<td><input type="button" value="%" onclick="display('%')" id="btn" /></td>
</tr>
<tr>
<td><input type="button" value="(" onclick="display('(')" id="btn" /></td>
<td><input type="button" value="0" onclick="display('0')" id="btn" /></td>
<td><input type="button" value=")" onclick="display(')')" id="btn" /></td>
<td><input type="button" value="^" onclick="display('**')" id="btn" /></td>
<td><input type="button" value="," onclick="display(',')" id="btn" /></td>
</tr>
<tr>
<td><input type="button" value="log" onclick="display('Math.log(')" id="btn" /></td>
<td><input type="button" value="sqrt" onclick="display('Math.sqrt(')" id="btn" /></td>
<td><input type="button" value=" ! " onclick="display('!')" id="btn" /></td>
<td><input type="button" value=" pi " onclick="display('Math.PI')" id="btn" /></td>
<td><input type="button" value=" E " onclick="display('Math.E')" id="btn" /></td>
</tr>
<tr>
<td><input type="button" value="sin" onclick="display('sin(')" id="btn" /></td>
<td><input type="button" value="cos" onclick="display('cos(')" id="btn" /></td>
<td><input type="button" value="tan" onclick="display('tan(')" id="btn" /></td>
<td><input type="button" value="deg" onclick="change()" id="btn1" /></td>
<td><input type="button" value="his" onclick="history()" id="btn" /></td>
</tr>
</table>
<br>
<h1>History:</h1>
<textarea id="his" name="history" rows="8" cols="50"></textarea>
</center>
<script src="script.js"></script>
</body>
</html>
56 changes: 56 additions & 0 deletions calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
function display(a){
document.getElementById("scrn").value+=a;
}
function clearAll(){
document.getElementById("scrn").value="";
}
let s="";
function calculate(){
s+=document.getElementById("scrn").value;
s+='=';
document.getElementById("scrn").value=eval(document.getElementById("scrn").value);
s+=document.getElementById("scrn").value;
s+='\n';
}
function cut(){
let a=document.getElementById("scrn").value;
document.getElementById("scrn").value=a.slice(0,a.length-1)
}
let d=0;
function sinD(angleDegrees) {
return Math.sin(angleDegrees*Math.PI/180);
};
function cosD(angleDegrees) {
return Math.cos(angleDegrees*Math.PI/180);
};
function tanD(angleDegrees) {
return Math.tan(angleDegrees*Math.PI/180);
};
function sin(a){
if(d===1)return sinD(a);
else {
return Math.sin(a);
}
}
function cos(a){
if(d===1)return cosD(a);
else return Math.cos(a);
}
function tan(a){
if(d===1)return tanD(a);
else return Math.tan(a);
}
function change(){
if(d==1){
d=0;
document.getElementById("btn1").value="deg";
}
else {
d=1;
document.getElementById("btn1").value="rad";
}
}
function history(){
document.getElementById("his").innerHTML=s;
}

75 changes: 75 additions & 0 deletions calculator/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#btn{
padding: 15;
font-size: 30;
width: 100%;
background-color: rgb(214, 234, 252);
border: 0px;
}
#btn1{
padding: 15;
font-size: 30;
width: 100%;
background-color: rgb(214, 234, 252);
border: 0px;
}
#scrn{
padding: 20px;
font-size: large;
background-color: rgb(99, 99, 99);
color: white;
text-align: right;
}
table{
padding: 60px;
border: 2px solid;
background-color: rgb(32, 108, 128);
margin-top: 40px;
}
body{
background-color: rgb(229, 242, 254);
}
#his{
font-size: x-large;
}
header{
background-color: rgb(32, 108, 128);
display: inline-block;
padding: 20px;
color: aliceblue;
margin: 10px;
padding-left: 60px;
padding-right: 60px;
font-size: 50px;
}
@media only screen and (max-width: 1000px) {
table{
margin: 0px;
margin-top: 40px;
}
#btn{
padding: 25;
font-size: 55;
width: 100%;
background-color: rgb(214, 234, 252);
border: 0px;

}
#btn1{
padding: 25;
font-size: 55;
width: 100%;
background-color: rgb(214, 234, 252);
border: 0px;

}
#scrn{
padding: 30px;
font-size: xx-large;
background-color: rgb(99, 99, 99);
color: white;
}
#his{
font-size: xx-large;
s="";
}
}