Welcome, Visitor!

Hello, we are really happy that you have reached us. However, since you are viewing the forum as a visitor, you cannot benefit from many features of the forum. How about taking advantage of all the features exclusive to our members by registering? You can register right now, taking just 2 minutes of your time. We would love to see you among us.

JavaScript Yazılı Ortalaması ve Geçti Kaldı Örneği

S

Shiva

Manager
Thread Starter
Admin
Joined
Jul 31, 2019
Messages
4,049
Reaction score
9,138
Points
113
Location
Berlin
JavaScript ile kullanıcıdan form ile 2 yazılı notunu alan ve yazılı ortalamasını ve Geçme Kalma durumunu gösteren JavaScript kodları:

Kullanıcının girdiği yazılı notlarına göre ortalaması hesaplanarak, ortalamanın 50 ve üstü olması durumunda Geçti, diğer durumda ise Kaldı yazdırılacaktır.


javaScript-Ortalama-Hesapla-1.jpg


HTML+JavaScript Kodları:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>algoritmaornekleri.com</title>
</head>

<body>
<h2>Yazılı Ortalaması Hesapla</h2>
<input placeholder="1. Yazılıyı Girin" type="text" id="txtY1">
<input placeholder="2. Yazılıyı Girin" type="text" id="txtY2">
<button id="btn">HESAPLA</button>
<div id="sonucOrtalama"></div>
<div id="sonucDurum"></div>

<script>
function Hesapla()
{
var durum="";
var y1=Number(document.getElementById("txtY1").value);
var y2=Number(document.getElementById("txtY2").value);
var ortalama=(y1+y2)/2;
if(ortalama>=50)
{
durum="Geçti";
}
else
{
durum="Kaldı";
}
document.getElementById("sonucOrtalama").innerHTML="Ortalama : "+ortalama;
document.getElementById("sonucDurum").innerHTML="Durum : "+durum;
}

var hesapBtn=document.getElementById("btn");
hesapBtn.onclick=Hesapla;

</script>

</body>
</html>
javaScript-Ortalama-Hesapla-4.jpg
 
N

Nemesis

Passive Member
Joined
Dec 21, 2019
Messages
119
Reaction score
28
Points
18
Yararlı Konu Güzel ++
 
SPAM IS FORBIDDEN!
  • SPAMMERS ARE BANNED FROM THE FORUM AND CANNOT USE ANY OF THE CHEATS
  • For example: thanks, thx, very good, asdqwe, working, ty and so on!
  • For example: Writing the same message over and over. thanks, thx and so on!
  • Copying and copying someone else's message is prohibited.
  • It is forbidden to send messages to increase the number of comments on threads that you have no knowledge of.
  • Write your own opinion when commenting!
  • If you see spam message, please let us know with the REPORT button!

Theme editor

Top Bottom