0% found this document useful (0 votes)
31 views3 pages

Latihan 2 Web Client - Java Script

The document describes a simple JavaScript arithmetic application. It contains code to create a basic calculator with fields for two numbers and a result field. It includes JavaScript functions for addition, subtraction, multiplication, division, and exponents which calculate the result and display it. There are also functions to initialize the fields and clear them. The code is embedded in an HTML page to display the calculator interface and call the JavaScript functions on button clicks to perform the calculations.

Uploaded by

jarotdian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views3 pages

Latihan 2 Web Client - Java Script

The document describes a simple JavaScript arithmetic application. It contains code to create a basic calculator with fields for two numbers and a result field. It includes JavaScript functions for addition, subtraction, multiplication, division, and exponents which calculate the result and display it. There are also functions to initialize the fields and clear them. The code is embedded in an HTML page to display the calculator interface and call the JavaScript functions on button clicks to perform the calculations.

Uploaded by

jarotdian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

LATIHAN 2 JAVA SCRIPT

MEMBUAT APLIKASI ARITMATIKA SEDERHANA

Kode Program :

<html>
<title> Tugas Pembuatan Project </title>

<head>

<SCRIPT LANGUAGE="JavaScript">
function tambah()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a+b
form.hasil.value = c
}
function kurang()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a-b
form.hasil.value=c
}
function kali()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a*b
form.hasil.value=c
}
function bagi()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a/b
form.hasil.value = c
}
function pangkat()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=Math.pow(a, b)
form.hasil.value = c
}
function kosong()
{
form.a.focus()
form.a.value=""
form.b.value=""
form.hasil.value=""
}

</SCRIPT>
</head>
<body onload=kosong() background-color="blue">
<CENTER>
<font size="6">Tugas Pembuatan Project </font>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">Simple Calculator</div>
<div class="panel-body">
<FORM name="form">

<div class="form-inline" role="form">


<label for="angka1">Angka 1 </label>
<input type="text" name="a" class="form-control"></br>

</div>
<div class="form-inline" role="form">
<label for="angka1">Angka 2 </label>
<input type="text" name="b" class="form-control"></br>

</div><br>
<div class="form-inline" role="form">
Hasil <input type “text" name="hasil" disabled="true" class="form-control"></br></br>
</div>

<input type="button" class="btn btn-info" value=" + " onClick="tambah()">


<input type="button" class="btn btn-info" value=" - " onClick="kurang()">
<input type="button" class="btn btn-info" value=" x " onClick="kali()">
<input type="button" class="btn btn-info" value=" / " onClick="bagi()">
<input type="button" class="btn btn-info" value=" ^ " onClick="pangkat()">
<input type="button" class="btn btn-danger" value=" Hapus " onClick="kosong()">

<br>

</FORM>
</div>
</div>
</div>

</CENTER>
<pre>
<p align="center">Creat By STEKOM</p>
</pre>

</body>
</html>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy