Sunday, July 24, 2016

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)
}




Centimeter To Kilometer Program in Rust

A simple program that I wrote that will ask the user to give length in centimeter and then it will convert into kilometer equivalent 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

kilometer.rs


// Centimeter To Kilometer 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!("\tCentimeter To Kilometer Program in Rust");
       println!("\n");

    let cm: f32 = grab_input("Give length in centimeter ")
        .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_km = cm / 100000.0;
                  
    println!("\n"); 
    println!("The length in centimeter is {:.2} cm its equivalent in kilometer(s) is {:.2} km.",cm,solve_km);
    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)
}




Centimeter To Meter Converter Using Rust

A simple program that I wrote that will ask the user to give length in centimeter and then it will convert into Meter equivalent 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

meter.rs


// Centimer To Meter 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!("\tCentimeter To Meter Program in Rust");
       println!("\n");
    let cm: f32 = grab_input("Give length in centimeter ")
        .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_meter = cm / 100.0;
                 
    println!("\n"); 
    println!("The length in centimeter is {:.2} its equivalent in meters is {:.2}.",cm,solve_meter);
    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)
}



Celsius To Fahrenheit Program in Rust

A simple program that I wrote that will ask the user the temperature Celsius and then it will convert into Fahrenheit equivalent 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

// Celsius To Fahrenheit 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!("\tCelsius To Fahrenheit Program in Rust");
       println!("\n");

    let celsius: f32 = grab_input("Give temperature in Celsius  ")
        .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_fahrenheit = (celsius * 1.8) + 32.0;
                 
    println!("\n"); 
    println!("The temperature in Celsius is {:.2} its equivalent in Fahrenheit is {:.2}.",celsius,solve_fahrenheit);
    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)
}


Fahrenheit To Celsius Program in Rust

A simple program that I wrote that will ask the user the temperature in Fahrenheit and then it will convert into Celsius equivalent 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

fahrenheit.rs

// Fahrenheit To Celsius 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!("\tFahrenheit To Celsius Program in Rust");
       println!("\n");
 
    let fahren: f32 = grab_input("Give temperature in Fahrenheit  ")
        .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_celsius = (fahren-32.0)* 5.0/9.0;
                
    println!("\n"); 
    println!("The temperature in Fahrenheit is {:.2} its equivalent in Celsius is {:.2}.",fahren,solve_celsius);
    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)
}

Decimal To Octal Converter Using Rust

A simple program that I wrote in Rust programming language that will ask the user to give a number and then our program will convert the number given by our user into octal equivalent.

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



// Decimal To Octal 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!("\tDecimal To Octal Program in Rust");
       println!("\n");
 
    let number: i32 = grab_input("Enter a Number ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

        
    println!("\n"); 
    println!("The Octal value of {} is {:o}.",number,number);
    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)
}