Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Completed All Task #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
59 changes: 59 additions & 0 deletions kamal praneeth/Calculater/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>pk
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1 style="color: blueviolet;">KAMAL'S CALCULATOR</h1>
<div class="calculator dark">
<div class="theme-toggler active">
<i class="toggler-icon"></i>
</div>
<div class="display-screen">
<div id="display"></div>
</div>
<div class="button">
<table>
<tr>
<td><button class="btn-operator" id="clear">C</button></td>
<td><button class="btn-operator" id="/">&divide;</button></td>
<td><button class="btn-operator" id="*">&times;</button></td>
<td><button class="btn-operator" id="backspace">&laquo;</button></td>
</tr>
<tr>
<td><button class="btn-number" id="7">7</button></td>
<td><button class="btn-number" id="8">8</button></td>
<td><button class="btn-number" id="9">9</button></td>
<td><button class="btn-operator" id="-">-</button></td>
</tr>
<tr>
<td><button class="btn-number" id="4">4</button></td>
<td><button class="btn-number" id="5">5</button></td>
<td><button class="btn-number" id="6">6</button></td>
<td><button class="btn-operator" id="+">+</button></td>
</tr>
<tr>
<td><button class="btn-number" id="1">1</button></td>
<td><button class="btn-number" id="2">2</button></td>
<td><button class="btn-number" id="3">3</button></td>
<td rowspan="2"><button class="btn-equal" id="equal">=</button></td>
</tr>
<tr>
<td><button class="btn-operator" id="(">&#40;</button></td>
<td><button class="btn-number" id="0">0</button></td>
<td><button class="btn-operator" id=")">&#41;</button></td>
</tr>
</table>
</div>
</div>
</div>

<!-- JavaScript code -->
<script src="script.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions kamal praneeth/Calculater/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const display = document.querySelector("#display");
const buttons = document.querySelectorAll("button");

buttons.forEach((item) => {
item.onclick = () => {
if(item.id == "clear") {
display.innerText = "";
}
else if (item.id == "backspace") {
let string = display.innerText.toString();
display.innerText = string.substr(0, string.length - 1);
}
else if(display.innerText != "" && item.id == "equal") {
display.innerText = eval(display.innerText);

}
else if (display.innerText == "" && item.id == "equal") {
display.innerText = "Empty!";
setTimeout(() => (display.innerText = ""), 2000);
}
else {
display.innerText += item.id;
}
};
});

const themeToggleBtn = document.querySelector(".theme-toggler");
const calculator = document.querySelector(".calculator");
const toggleIcon = document.querySelector(".toggler-icon");
let isDark = true;
themeToggleBtn.onclick = () => {
calculator.classList.toggle("dark");
themeToggleBtn.classList.toggle("active");
isDark = !isDark;
};
161 changes: 161 additions & 0 deletions kamal praneeth/Calculater/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
* {
padding: 0;
margin: 0;
box-sizing: border-box;
outline: 0;
transition: all 0.5s ease;
}

body {
font-family: sans-serif;
}

a {
text-decoration: none;
color: #fff;
}

body {
background: rgb(184, 98, 175);
}

.container {
height: 100vh;
width: 100vw;
display: grid;
place-items: center;
}

.calculator {
position: relative;
height: auto;
width: auto;
padding: 20px;
border-radius: 10px;
/* box-shadow: 0 0 30px #000; */
}

.theme-toggler {
position: absolute;
top: 30px;
right: 30px;
color: #fff;
cursor: pointer;
z-index: 1;
}

.theme-toggler.active {
color: #333;
}

.theme-toggler.active::before {
background-color: #fff;
}

.theme-toggler::before {
content: '';
height: 30px;
width: 30px;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
background-color: #333;
z-index: -1;
}

#display {
margin: 0 10px;
height: 150px;
width: auto;
max-width: 270px;
display: flex;
align-items: flex-end;
justify-content: flex-end;
font-size: 30px;
margin-bottom: 20px;
overflow-x: scroll;
}

#display::-webkit-scrollbar {
display: block;
height: 3px;
}

button {
height: 60px;
width: 60px;
border: 0;
border-radius: 50%;
margin: 10px;
font-size: 20px;
cursor: pointer;
transition: all 200ms ease;
}

button:hover {
transform: scale(1.1);
}

button#equal {
height: 140px;
border-radius: 30px;
}

/* light theme */
.calculator {
background-color: #fff;
}

.calculator #display {
color: #0a1e23;
}

.calculator button#clear {
background-color: #ffd5d8;
color: #fc4552;
}

.calculator button.btn-number {
background-color: #c3eaff;
color: #000;
}

.calculator button.btn-operator {
background-color: #ffd0fd;
color: #f967f3;
}

.calculator button.btn-equal {
background-color: #adf9e7;
color: #000;
}

/* Dark theme */
.calculator.dark {
background-color: #071115;
}

.calculator.dark #display {
color: #f8fafd;
}

.calculator.dark button#clear {
background-color: #2d191e;
color: #bd3740;
}

.calculator.dark button.btn-number {
background-color: #1b2f38;
color: #f8fafd;
}

.calculator.dark button.btn-operator {
background-color: #2e1f39;
color: #aa00a4;
}

.calculator.dark button.btn-equal {
background-color: #223323;
color: #fff;
}
3 changes: 3 additions & 0 deletions kamal praneeth/Quiz/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
36 changes: 36 additions & 0 deletions kamal praneeth/Quiz/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!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>Quiz App</title>
</head>
<body>
<div class="quiz-container" id="quiz">
<div class="quiz-header">
<h2 id="question">Question Text</h2>
<ul>
<li>
<input type="radio" name="answer" id="a" class="answer">
<label for="a" id="a_text">Answer</label>
</li>
<li>
<input type="radio" name="answer" id="b" class="answer">
<label for="b" id="b_text">Answer</label>
</li>
<li>
<input type="radio" name="answer" id="c" class="answer">
<label for="c" id="c_text">Answer</label>
</li>
<li>
<input type="radio" name="answer" id="d" class="answer">
<label for="d" id="d_text">Answer</label>
</li>
</ul>
</div>
<button id="submit">Submit</button>
</div>
<script src="script.js"></script>
</body>
</html>
83 changes: 83 additions & 0 deletions kamal praneeth/Quiz/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const quizData = [
{
question: "Which language runs in a web browser?",
a: "Java",
b: "C",
c: "Python",
d: "javascript",
correct: "d",
},
{
question: "What does CSS stand for?",
a: "Central Style Sheets",
b: "Cascading Style Sheets",
c: "Cascading Simple Sheets",
d: "Cars SUVs Sailboats",
correct: "b",
},
{
question: "What does HTML stand for?",
a: "Hypertext Markup Language",
b: "Hypertext Markdown Language",
c: "Hyperloop Machine Language",
d: "Helicopters Terminals Motorboats Lamborginis",
correct: "a",
},
{
question: "What year was JavaScript launched?",
a: "1996",
b: "1995",
c: "1994",
d: "none of the above",
correct: "b",
},
];
const quiz= document.getElementById('quiz')
const answerEls = document.querySelectorAll('.answer')
const questionEl = document.getElementById('question')
const a_text = document.getElementById('a_text')
const b_text = document.getElementById('b_text')
const c_text = document.getElementById('c_text')
const d_text = document.getElementById('d_text')
const submitBtn = document.getElementById('submit')
let currentQuiz = 0
let score = 0
loadQuiz()
function loadQuiz() {
deselectAnswers()
const currentQuizData = quizData[currentQuiz]
questionEl.innerText = currentQuizData.question
a_text.innerText = currentQuizData.a
b_text.innerText = currentQuizData.b
c_text.innerText = currentQuizData.c
d_text.innerText = currentQuizData.d
}
function deselectAnswers() {
answerEls.forEach(answerEl => answerEl.checked = false)
}
function getSelected() {
let answer
answerEls.forEach(answerEl => {
if(answerEl.checked) {
answer = answerEl.id
}
})
return answer
}
submitBtn.addEventListener('click', () => {
const answer = getSelected()
if(answer) {
if(answer === quizData[currentQuiz].correct) {
score++
}
currentQuiz++
if(currentQuiz < quizData.length) {
loadQuiz()
} else {
quiz.innerHTML = `
<h2>You answered ${score}/${quizData.length} questions correctly</h2>
<button onclick="location.reload()">Reload</button>
`
}
}
})
Loading