Calculate simple interest

Simple interest calculator

C Programming

#include<stdio.h>
int main() {
int p,t;
float r,si;
printf("Enter principal,time and rate: ");
scanf("%d%d%f",&p,&t,&r);
si = p * t * r / 100;
printf("Simple Interest = %.2f",si);
return 0;
}

C++ Programming

#include<iostream>
using namespace std;
int main() {
int p,t;
float r;
cout << "Enter principal, time and rate: ";
cin >> p >> t >> r;
float si = p * t * r / 100;
printf("Simple Interest = %.2f",si);
return 0;
}

Java Programming

import java.util.Scanner;
class SimpleInterest {
public static void main(String args[]) {
int p,t;
float r,si;
Scanner sc = new Scanner(System.in);
System.out.print("Enter principal, time and rate: ");
p = sc.nextInt();
t = sc.nextInt();
r = sc.nextFloat();
si = p * t * r / 100;
System.out.println("Simple interest = "+si);
}
}

Go lang

package main
import "fmt"
func main() {
var p,t int32
var r float32
fmt.Print("Enter principal, time and rate: ")
fmt.Scan(&p,&t,&r)
si := float32(p) * float32(t) * r / float32(100)
fmt.Println("Simple Interest: ",si)
}

PHP

index.html

<!doctype html>
<html>
<head>
<title>Sum of two numbers</title>
</head>
<body>
<form method="post" action="doSum.php">
<p>Principal: <input type="text" name="p"></p>
<p>Rate: <input type="text" name="r"></p>
<p>Time: <input type="number" name="t"> (In year) </p>
<p><input type="submit" name="sub" value="Calculate Simple Interest"></p>
</form>
</body>
</html> 

doSimpleInterest.php

<?php
if(isset($_POST['sub'])) {
$p = $_POST['p'];
$r = $_POST['r'];
$t = $_POST['t'];
$si = $p * $t * $r / 100;
echo "Simple Interest = ".$si;
}
?> 

Comments

Popular posts from this blog

Overview of Go lang

Arrays in C Language

Data Types in Go language

Creating your first html page

Say Hello world in Go lang

Arrays in Go lang

Installing go lang

String in golang

Decision Making in Go lang

Decision Making Statements