Friday, July 29, 2016

Product Cost Program in Rust

A program that I wrote using Rust programming language that will ask the user the cost of the product and its quantity after which it will compute its total cost. The code is very simple and intended for beginners in Rust programming.

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

// Product Cost Program in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 28, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;


fn main() {
       println!("\n");
       println!("\tProduct Cost Program in Rust");
       println!("\n");

    let price: f32 = grab_input("Enter the price of the item ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));


    let quantity: f32 = grab_input("Enter the quantity of the item  ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

     let  solve_cost = price * quantity;
              
    println!("\n"); 
    println!("The total cost of the product is  $ {:.2}.",solve_cost);
    println!("\n");  
    println!("End of Program");
}



fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());

    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}

fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}




Year Level Checker in Rust

A simple program that I wrote using Rust programming language that will ask the user what is its year level and then our program will determine whether the user is freshmen, sophomore, junior or senior. 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


// Year Level Checker in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 28, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;
 
fn main() {
       println!("\n");
       println!("\tYear Level Checker in Rust");
       println!("\n");
 
    let year: i32 = grab_input("Enter the Year Level of the Student  ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

   if year == 1 {
    println!("\n"); 
    println!("You are belong to Freshmen.");
  }
  else if year == 2 {
    println!("\n"); 
    println!("You are belong to Sophomore.");
else if year == 3 {
    println!("\n"); 
    println!("You are belong to Juniors.");
else if year == 4 {
    println!("\n"); 
    println!("You are belong to Seniors.");
else {
    println!("\n");
    println!("Sorry Invalid Year Level !!! Try again.");
   }
 
    println!("\n"); 
    println!("End of Program");
}
 
fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());
 
    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}
 
fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}


Circle Calculator in PHP

In this article I would like to share with you a sample program that I wrote in PHP I called this program Circle Calculator. What does the program will do is to ask the user to give the radius of the circle and then our program will compute the area and circumference of the circle. The code is very easy to understand and use. I hope you will find my work useful thank you.


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>
<style>
  body {
    font-size: 20;
    font-family:sans-serif;
    font-weight: bold;
  }
input {
    font-size: 20px;
    font-weight: bold;
   }

  /* http://cssdemos.tupence.co.uk/button-styling.htm */ 
  input#shiny {
padding: 4px 20px;
/*give the background a gradient*/
background:#ffae00; /*fallback for browsers that don't support gradients*/
background: -webkit-linear-gradient(top, blue,blue);
background: -moz-linear-gradient(top, blue, blue);
background: -o-linear-gradient(top, blue, blue);
background: linear-gradient(top, blue, blue);
border:2px outset #dad9d8;
/*style the text*/
font-family:Andika, Arial, sans-serif; /*Andkia is available at http://www.google.com/webfonts/specimen/Andika*/
font-size:1.1em;
letter-spacing:0.05em;
text-transform:uppercase;
color:#fff;
text-shadow: 0px 1px 10px #000;
/*add to small curve to the corners of the button*/
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
/*give the button a drop shadow*/
-webkit-box-shadow: rgba(0, 0, 0, .55) 0 1px 6px;
-moz-box-shadow: rgba(0, 0, 0, .55) 0 1px 6px;
box-shadow: rgba(0, 0, 0, .55) 0 1px 6px;
}
/****NOW STYLE THE BUTTON'S HOVER STATE***/
input#shiny:hover, input#shiny:focus {
border:2px solid #dad9d8;
}
 </style>
<body>
  <?php
  $values = $_POST['inputText'];


  if(isset($_POST['ClearButton'])){
  $values = "";

  }

   ?>
  <br>
  <h4> Circle Calculator </h4>
  <form action="" method="post">
  What is the Radius of the Circle?
  <input type="text" name="inputText" size="5" maxlength="5"
  value="<?php echo $values; ?>"  style="width:100px; height:30px;" required autofocus=""/>
  <br><br>
  <input id="shiny" type="submit" value="Ok" name="SubmitButton"/>
  &nbsp;&nbsp;&nbsp;
  <input id="shiny" type="submit" value="Clear" name="ClearButton"/>
</form>
<?php

$values = $_POST['inputText'];
if(isset($_POST['SubmitButton'])){

$r = (int)$values;
$p=3.14159;

$Area= $p*pow($r,2);
$Circumference=$p*$r*2;
$Diameter= 2*$r;

echo "<br>";
echo "The Area of Circle is : ".number_format($Area,2,'.','')."m";
$str = "&sup2;";
echo $str;
echo "<br>";
echo "The Diameter of Circle is : ".number_format($Diameter,2,'.','');
echo "<br>";
echo "Circumference of Circle is : ".number_format($Circumference, 2, '.', '')."m";

}
?>

</body>
</html>






Sunday, July 24, 2016

Payroll Program in Turbo Pascal

In this article I would like to share with you a sample program that I wrote using Pascal as my language of choice. I called this program Payroll Program in Turbo Pascal. What does the program will do is to ask the user the name of the employee and then it will ask the number of days work. After which the program will compute the salary of the employee. I am using Turbo Pascal 6 For DOS as my compiler in writing 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

Program Payroll;
Uses Crt;

Const rate = 5.50;

Var  employee : string;
     days     : integer;
     total    : real;

Begin

Clrscr;
Writeln('Payroll Program in Pascal');
Writeln;
Write('Give Employees Name :');
Readln(employee);
Write('Give Number of Days Worked : ');
Readln(days);

Total := (days * rate);

    Writeln;
Write('Display Payroll Result');
Writeln;
        Writeln;
        Write('Employees Name : ' ,employee);
        Writeln;
Write('For ',days:2, ' days of work, you have earned $');
Write(total:5:2);
Writeln;
    Writeln;
Write('End of Program');
Readln;
End.
    


Triangle Pattern in Turbo Pascal

In this article I would like to share with you a sample program that I wrote using Pascal as my programming language. It will create and generate an triangle image using asterisk symbol on the screen. By the way I am using Turbo Pascal 6.0 for DOS as my compiler in writing this sample program.  Thank you very much.

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

Program Triangle_Pattern;

Uses Crt;

Const image ='*';

Var A,B :integer;

Begin
 Clrscr;
 For A  := 1 to 10 Do
  Begin
   For B := 1 To 10 - A Do
     write(' ');
   For B := 1 To 2 * A - 1 Do
     Write(Image);
   writeln;
  End;
 Writeln;
 Writeln('Triagle Pattern in Pascal');
 Readln;
End.





Multiplication Table in Pascal

I there for couple of days I was not able to upload new tutorial because I don't have available internet connection at home for the moment. Anyway this article I would like to share with you how to create a multiplication table using Pascal as our programming language. I am using Turbo Pascal 6.0 for DOS as my Pascal compiler in this sample program. What does the program will do is to generate multiplication table using for loop statement in Pascal. I hope you will find my work useful. Thank you very much.


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

Program Multiplication_Table_Pascal;

Uses Crt;

Var i,j : Integer;

Begin
Clrscr;
Gotoxy(20,1);
        Writeln('Multiplication Table in Pascal');
Writeln;
        Gotoxy(12,3);
Writeln('Created By: Mr. Jake R. Pomperada, MAED-IT 2016.');
Writeln;
        Write('     ');
For J := 1 to 12 Do
 Write(j:5);
 Writeln;
For I := 1 to 12 Do
 Begin
  Write(i:5);
  For J := 1 To 12 Do
    Write(i*j:5);
  Writeln;
End;
Readln;
End.

Sunday, July 17, 2016

Simple Interest Rate Solver in Rust

A simple program that will compute the loan of the person based on the principal amount loan, interest rate and time duration of the loan using Rust as my programming language.

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

interest.rs

// Simple InterestProgram in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 17, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;


fn main() {
       println!("\n");
       println!("\tSimple Interest Program in Rust");
       println!("\n");

       
    let  principal: f32 = grab_input("Enter Principal Amount $ ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

   let  rate: f32 = grab_input("Enter Rate of Interest $ ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

 let  time: f32 = grab_input("Enter Period of Time  ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

   let solve_interest = (principal * rate * time) / 100.0;
              
    println!("\n"); 
    println!("The simple interest is {:.2}.",solve_interest);
    println!("\n");  
    println!("End of Program");
}

fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());

    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}

fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}


Circumference of the Circle Solver in Rust

A simple program that will ask the user to give the radius of the circle and then our program will solve for the circumference of the circle using Rust as our programming language.

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

circumference.rs

// Circuference of the Circle Program in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 17, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;


fn main() {
       println!("\n");
       println!("\tCircumference of the Circle Program in Rust");
       println!("\n");

       let pi : f32 = 3.1416; 

    let radius: f32 = grab_input("Enter the radius of the circle ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

     let  solve_circumference = 2.0 * pi * radius;
              
    println!("\n"); 
    println!("The given radius is {:.2} the circumference of the circle is {:.2}.",radius,solve_circumference);
    println!("\n");  
    println!("End of Program");
}



fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());

    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}

fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}



Area of the Circle Solver in Rust

A simple program that will ask the user to give the radius of the circle and then our program will solve for the area of the circle using Rust as our programming language.

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

circle.rs

// Area of the Circle Program in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 17, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;


fn main() {
       println!("\n");
       println!("\tArea of the Circle Program in Rust");
       println!("\n");

       let pi : f32 = 3.1416; 

    let radius: f32 = grab_input("Enter the radius of the circle ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

     let  solve_area = pi * radius * radius;
                  
    println!("\n"); 
    println!("The given radius is {:.2} the area of the circle is {:.2}.",radius,solve_area);
    println!("\n");  
    println!("End of Program");
}

fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());

    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}

fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}