Monday, September 26, 2016

Interest Rate Solver in Text File in C++

A simple program that I wrote a long time ago in C++ that will compute the interest rate of the amount being loaned and then save the results in a text file.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <iomanip>
#include <fstream>


using namespace std;

main() {

    string name;

    int principal=0;
    int number_months=0;
    float rate=0.00,solve_rate=0.00;

    ofstream file("report.txt");

    cout << "\t  Kwarta Agad Lending Investor";
    cout << "\n\n";
    cout << "Enter Customer Name    :=> ";
    getline(cin,name);
    cout << "\nEnter Amount  Loan   :=> ";
    cin >> principal;
    cout << "\nNumber of Months    :=> ";
    cin >> number_months;
    cout << "\nEnter Rate Per Month :=> ";
    cin >> rate;
    solve_rate = (principal * number_months * rate ) ;
    cout << "\n\n";
    cout << fixed << setprecision(2);
    cout << "The Simple Interest Rate is Php "
         << solve_rate << ".";

    file << "\n\t ======= Kwarta Agad Lending Investor =========";
    file << "\n\n";
    file << "\n\t\t CUSTOMER REPORT";
    file << "\n\n";
    file << "\n Customer Name     : " << name;
    file << "\n Amount   Loan     : " << principal;
    file << "\n Number of Months  : " << number_months;
    file << "\n Rate Per Month    : " << rate;
    file << "\n\n";
    file << fixed << setprecision(2);
    file << "\n Interest Rate is Php " << solve_rate;
    file.close();
    cout << "\n\n";
    system("pause");
}

Roman Numeral To Decimal in PERL

A simple program that I wrote using PERL as my programming language that will ask the user to give roman numeral value and then our program will convert the given roman numeral value into it's decimal equivalent in PERL.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

#!D:\xampp\perl\bin

our @EXPORT = qw(isroman arabic Roman roman);

our %roman2arabic = qw(I 1 V 5 X 10 L 50 C 100 D 500 M 1000);

starting();

sub isroman($) {
    my $arg = shift;
    $arg ne '' and
      $arg =~ /^(?: M{0,3})
                (?: D?C{0,3} | C[DM])
                (?: L?X{0,3} | X[LC])
                (?: V?I{0,3} | I[VX])$/ix;
}

sub arabic($) {
    my $arg = shift;
    isroman $arg or return undef;
    my($last_digit) = 1000;
    my($arabic);
    foreach (split(//, uc $arg)) {
        my($digit) = $roman2arabic{$_};
        $arabic -= 2 * $last_digit if $last_digit < $digit;
        $arabic += ($last_digit = $digit);
    }
    $arabic;
}
sub starting {
        print "\n\n";
        print "\t Roman Numeral To Decimal in PERL.";
        print "\n\n";
        print "Enter a Roman Numeral : ";
        chomp($a=<>);
        print "\n\n";
        print "The roman numeral $a equivalent is ";
        print uc(arabic($a));
        print ".";
        print "\n\n";
        print "Do you want to continue (Y or N) ? : ";
        chomp($choice=<>);
        if( $choice eq "y") {
            goto &starting;
          } else {
            print "\n\n";
            print "\t End of Program";
            print "\n";
            exit;

        }
 }

Decimal To Roman Numeral in PERL

A simple program that I wrote using PERL as my programming language that will ask the user to give decimal value and then our program will convert the given decimal value into roman numeral equivalent in PERL.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

#!D:\xampp\perl\bin

my %roman_digit = qw(1 IV 10 XL 100 CD 1000 MMMMMM);
my @figure = reverse sort keys %roman_digit;
$roman_digit{$_} = [split(//, $roman_digit{$_}, 2)] foreach @figure;

starting();

sub Roman($) {
    my $arg = shift;
    0 < $arg and $arg < 4000 or return undef;
    my($x, $roman);
    foreach (@figure) {
        my($digit, $i, $v) = (int($arg / $_), @{$roman_digit{$_}});
        if (1 <= $digit and $digit <= 3) {
            $roman .= $i x $digit;
        } elsif ($digit == 4) {
            $roman .= "$i$v";
        } elsif ($digit == 5) {
            $roman .= $v;
        } elsif (6 <= $digit and $digit <= 8) {
            $roman .= $v . $i x ($digit - 5);
        } elsif ($digit == 9) {
            $roman .= "$i$x";
        }
        $arg -= $digit * $_;
        $x = $i;
    }
    $roman;
}

sub roman($) {
    lc Roman shift;
}

sub starting {
        print "\n\n";
        print "\t Decimal To Roman Numeral in PERL.";
        print "\n\n";
        print "Enter a number : ";
        chomp($a=<>);
        print "\n\n";
        print "The number $a it's roman numeral equivalent is ";
        print uc(roman($a));
        print ".";
        print "\n\n";
        print "Do you want to continue (Y or N) ? : ";
        chomp($choice=<>);
        if( $choice eq "y") {
            goto &starting;
          } else {
            print "\n\n";
            print "\t End of Program";
            print "\n";
            exit;

        }
 }

Calculator in PHP using Drop Down Menu

A simple calculator program that I wrote in PHP using Drop Down Menu to select the mathematical operator such as addition, subtraction, multiplication and division using combo box in HTML.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.







Sample Program Output


Program Listing

<html>
<head>
<?php
error_reporting(0);

 $a =  $_REQUEST['num1'];
 $b =  $_REQUEST['num2'];
?>

<title>Simple Calculator</title>
</head>
<style type="text/css">
 body
 {
 background-color:yellow;
 font-family:arial;
 font-size:14px;
 font-weight:bold;
 }

 #result
 {
 color:green;
 font-family:arial;
 font-size:16px;
 }



 input[type="text"] {
 height: 50px;
 width: 50px;
 font-family:arial;
 font-size:25px;
 font-weight:bold;
}

#opt{
 width:250px;   
}
</style>
<script language="javascript">
 function validate_form()
 {
 var num1 = document.entryform.num1;
 var num2 = document.entryform.num2;
 if (num1.value=="" || num1.value==null)
 {
 alert("Please specify value on first box");
 num1.focus();
 return false;
 }
 else if (num2.value=="" || num2.value==null)
 {
 alert("Please specify value on second box");
 num2.focus();
 return false;
 }
 }
</script>
<body>
<?php
if (isset($_REQUEST['clear']))
 {
  $a="";
  $b="";  
 }
 ?>
<form method="post" onSubmit="return validate_form(this)" name="entryform">
<fieldset>
 <legend>Simple Calculator</legend>
 <input type="text" name="num1" value="<?php echo $b; ?>"  autofocus>
 <select name="opt_math">
 <option value="+">+
 <option value="-">-
 <option value="*">*
 <option value="/">/
 </select>
 <input type="text" name="num2" value="<?php echo $a; ?>"><br><br>
 <input type="submit" name="submit" value="Compute"> &nbsp; &nbsp;
<input type="submit" name="clear" value="Clear">
 <br><br>

 <span id="result">
 Result is
 <strong>
 <?php
if ($_REQUEST['opt_math']=="+"){
 echo  $a+$b;
 }
 else if ($_REQUEST['opt_math']=="-"){
 echo $a-$b;
 }
 else if ($_REQUEST['opt_math']=="/"){
 echo $a/$b;
 }
 else if ($_REQUEST['opt_math']=="*"){
 echo $a*$b;
 }

 ?>
 </strong>
 </span><br><br><br>
  </fieldset>
 </form>
 </body>
 </html>



Count Capital and Small Letters in PHP

Here is a very short script that I wrote in PHP that will count the number of Capital and Small letter in a given string. The code is very simple to use and understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.



Program Listing


<?php

function CountCaps($string) {
  return strlen(preg_replace('/[^A-Z]+/', '', $string));
}

function CountSmall($string) {
  return strlen(preg_replace('/[^a-z]+/', '', $string));
}


$str = 'WeLcoMe HOme';

$result1 = CountCaps($str);

$result2 = CountSmall($str);

echo 'The word is ' .$str;
echo '<br><br>';
echo 'Number of Capital Letters ' .$result1.'.';
echo '<br><br>';
echo 'Number of Capital Letters ' .$result2.'.';

?>

Area of Rectangle in C#

Here is a another simple program that I wrote in C# to ask the user to give the length and breath of the rectangle and the our program will compute for its area. I am using Visual Studio 2010 Ultimate Edition in this program.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int length= 0, breadth=0,solve_area=0;

            if (!int.TryParse(textBox1.Text, out length))
            {
                MessageBox.Show("I need just a number in the textbox.");
                textBox1.Text = "";
                textBox2.Text = "";
                textBox1.Focus();
            }
            else  if (!int.TryParse(textBox2.Text, out breadth))
            {
                MessageBox.Show("I need just a number in the textbox.");
                textBox1.Text = "";
                textBox2.Text = "";
                textBox1.Focus();
            }


            else
            {
                length = Convert.ToInt32(textBox1.Text);
                breadth = Convert.ToInt32(textBox2.Text);

                solve_area = (length * breadth);
                label5.Text = "The Area of the Rectangle is " + solve_area + ".";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            label5.Text = " ";
            textBox1.Focus();
        }
    }
}







Area of Square Solver in C#

Here is a simple program that I wrote using C# as my programming language that will ask the user to give the side length of the square and then our program will compute the area of the square. The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int side = 0, area=0;

            if (!int.TryParse(textBox1.Text, out side))
            {
                MessageBox.Show("I need just a number in the textbox.");
                textBox1.Text = "";
                textBox1.Focus();
            }

            else
            {
                side = Convert.ToInt32(textBox1.Text);

                area = (side * side);
                label3.Text = "The Area of the Square is " + area + ".";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            label3.Text = "";
            textBox1.Focus();
        }
    }
}