Thursday, October 20, 2016

Math Calculator in C#

Here is a very simple console application that I wrote using C# programming language that will ask the user to give two numbers and then it will also ask the user to give an operand like plus sign, minus sign, slash sign and asterisk sign to process the two given input values. The code uses switch statement in C# and our program also ask the user do you want to continue in order for the user to repeat the process of the running the program.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 email address are the following 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.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1=0,num2=0,n=0;
            
            string reply,operand;

            float answer;
           
            do {

                Console.Clear();
                Console.Write("\n\n");
                Console.Write("Math Calculator ");
                Console.Write("\n\n");
                Console.Write("Give First Value : ");
                num1 = Convert.ToInt32(Console.ReadLine());
                Console.Write("Select an operand (+, -, /, *) : ");

               operand = Console.ReadLine();
            
              Console.Write("Give Second Value : ");
              num2 = Convert.ToInt32(Console.ReadLine());

              switch (operand)
                {

                  case "-":

                    answer = num1 - num2;

                    break;

                  case "+":

                    answer = num1 + num2;

                    break;

                  case "/":

                    answer = num1 / num2;

                    break;

                  case "*":

                    answer = num1 * num2;

                    break;

                   default:

                    answer = 0;

                    break;

            }
                Console.Write("\n\n");
                Console.Write("DISPLAY RESULT");
                Console.Write("\n\n");
                Console.WriteLine(num1.ToString() + " " + operand + " " + num2.ToString() + " = " + answer.ToString());
                Console.Write("\n\n");
                Console.Write("Do You Want To Continue? Y/N : ");
                reply = Console.ReadLine();

                if (reply == "y" || reply == "Y")
                {
                    continue;
                }
                else if (reply == "n" || reply == "N")
                {
                    Console.Write("\n\n");
                    Console.Write("Thank You For Using This Software.");
                    Console.Write("\n\n");
                    break;
                }

            } while (n == 0);
            Console.ReadLine();
        }
    }
}






Grading System Using Pointers in C++

Here is another C++ program that I wrote a very long time ago using Pointers that will ask the users grade and then our program will check if the user pass or failed in a particular subject. 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 email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>

using namespace std;

main() {
    int array[10];

    int *p;
    p = array;
    cout << "\t Grade Selector 1.0";
    cout << "\n\n";
    for (int a=0; a<10; a++)
     {

         cout << "\nEnter Grade No. " << a+1 << ":";
         cin >> p[a];
     }
     cout << "\n\n";
     cout << "\nGrade 90 To 100";
     cout << "\n";
     for (int a=0; a<10; a++)
     {

        if (p[a] >= 90 && p[a] <=100) {

        cout << "\n" <<p[a];
        }
     }
     cout << "\n\n";
     cout << "\nGrade 80 To 89";
     cout << "\n";
     for (int a=0; a<10; a++)
     {

        if (p[a] >= 80 && p[a] <=89) {

        cout << "\n" <<p[a];
        }
     }
     cout << "\n\n";
     cout << "\nGrade 75 To 79";
     cout << "\n";
     for (int a=0; a<10; a++)
     {

        if (p[a] >= 75 && p[a] <=79) {

        cout << "\n" <<p[a];
        }
     }
     cout << "\n\n";
     cout << "\nList of Failing Grades";
     cout << "\n";
     for (int a=0; a<10; a++)
     {

        if (p[a] < 75) {

        cout << "\n" <<p[a];
        }
     }
     cout << "\n\n";
     system("pause");
}

List a Number Without Using a Loop in C++

Here is a code that I wrote a very long time ago that will list a number from 1 to 50 without using any looping statement in C++ but rather it uses if statement.

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


My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <stdlib.h>

using namespace std;

int print(int num){
    if(num<=50){
         cout << " " << num << " ";
          print(num+1);
    }
}


int main(){
    int num = 1;
    cout << "\nList of Numbers Without Using a Loop in C++";
    cout <<"\n\n";
    print(num);
    cout <<"\n\n";
    cout << "\nEnd of Program";
    cout <<"\n\n";
    system("pause");

}


Prime Numbers in Ruby

Here is a simple program that will ask the user to give a number and then our program will generate the prime numbers based on the given number by our user using Ruby as our programming language.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.


Program Listing

prime_number.rb

  def get_prime_no_upto(number)
  start = 2
  primes = (start..number).to_a
  (start..number).each do |no|
    (start..no).each do |num|
      if ( no % num  == 0) && num != no
        primes.delete(no)
        break
      end
    end
  end
  primes
end

loop do
print "\n\n";
print "PRIME Numbers"
print "\n\n";
print "Enter a Number : ";
num_test = gets.chomp
print "\n\n";
print "List of Prime Numbers";
print "\n\n";
print get_prime_no_upto(num_test.to_i)
puts "\n\n";
print "Do you want to continue? (y/n) : "
  answer = gets.chomp.downcase
  if answer == "n"
print "\n\n";
    print "End of Program";
    print "\n\n";
break
  end
end

Object Creation in Ruby

Here is a very short program that I wrote using Ruby programming language to show you how to create an object. This program will not only create an object but also it will display a message of the screen.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.


Program Listing

object.rb

class Sample
   def hello
      puts "Hello Ruby!\n"
 puts "Ruby Demo Only.!\n"
   end
end

# Now using above class to create objects
demo = Sample.new
demo.hello

Number To Words in Ruby

Here is a simple and short program that I wrote using Ruby programming language that will ask the user to give a number and then our program will convert or translate the given number into words. 

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

num_words.rb

def number_words(int)
  numbers_to_name = {
      1000000000000 => "trillion",
      1000000000 => "billion",
      1000000 => "million",
      1000 => "thousand",
      100 => "hundred",
      90 => "ninety",
      80 => "eighty",
      70 => "seventy",
      60 => "sixty",
      50 => "fifty",
      40 => "forty",
      30 => "thirty",
      20 => "twenty",
      19=>"nineteen",
      18=>"eighteen",
      17=>"seventeen", 
      16=>"sixteen",
      15=>"fifteen",
      14=>"fourteen",
      13=>"thirteen",              
      12=>"twelve",
      11 => "eleven",
      10 => "ten",
      9 => "nine",
      8 => "eight",
      7 => "seven",
      6 => "six",
      5 => "five",
      4 => "four",
      3 => "three",
      2 => "two",
      1 => "one"
    }
  str = ""
  numbers_to_name.each do |num, name|
    if int == 0
      return str
    elsif int.to_s.length == 1 && int/num > 0
      return str + "#{name}"      
    elsif int < 100 && int/num > 0
      return str + "#{name}" if int%num == 0
      return str + "#{name} " + number_words(int%num)
    elsif int/num > 0
      return str + number_words(int/num) + " #{name} " + number_words(int%num)
    end
  end
end


loop do
print "\n\n";
print "Number To Words Program"
print "\n\n";
print "Enter a Number : ";
num_test = gets.chomp
num_test = num_test.to_i;
puts "\n\n";
print "The result is :=>  "
print number_words(num_test);
print "\n";
puts "\n\n";
    print "Do you want to continue? (y/n) : "
   answer = gets.chomp.downcase
  if answer == "n"
print "\n\n";
    print "End of Program";
    print "\n\n";
break
  end
end

Factorial in Ruby

In this simple program I called this program factorial in ruby what does the program will do is to ask the user to give a number and then our program will compute the factorial value of the given number by the user using Ruby as our programming language. I hope you like this program. Thank you.

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


My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

factorial.rb


def fact(n)
 puts 1.upto(n).inject('*')
end

loop do
print "\n\n";
print "Factorial Program"
print "\n\n";
print "Give a Number : ";
val1 = gets.chomp
val1 = val1.to_i;
print "\n\n";
print "The factorial value of #{val1} is "
print fact(val1);
print "\n\n";
print "Do you want to continue? (y/n) : "
answer = gets.chomp.downcase
  if answer == "n"
print "\n\n";
print "End of Program";
print "\n\n";
break
  end
end




Palindrome in Ruby

Here is a simple program that I wrote in Ruby programming language that will ask the user to give a string or a word and then our program will check if the given word or a string is a palindrome or not a palindrome. We can called a word a palindrome if we read the word forward and backward the spelling and the sound is the same. 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 email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

palindrome.rb

def check_palindrome(str)
  if str.reverse == str
    puts "\n\n";
    puts "The given word #{str} is a palindrome."
puts "\n";
  else
puts "\n";
    puts "The given word #{str} isn't a palindrome."
puts "\n";
  end
end

loop do
print "\n\n";
print "Palindrome Program"
print "\n\n";
print "Enter a String : ";
str_test = gets.chomp
check_palindrome(str_test.upcase)
puts "\n";
print "Do you want to continue? (y/n) : "
  answer = gets.chomp.downcase
  if answer == "n"
print "\n\n";
    print "End of Program";
    print "\n\n";
break
  end
end

Sunday, October 16, 2016

Payroll System in C#

Here is a simple payroll system that I wrote using Microsoft C# programming language this payroll system is based here in the Philippine setting for the deductions like tax, philhealth, sss, pag-ibig. Our program will ask the name of the employee, position of the employee, rate per day and number of days the employee work in the company and then our program will compute the gross pay, total deductions and finally the net pay of the salary of the employee. I hope you will like my work thank you.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

payroll.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// October 16, 2016  Sunday
// Author : Mr. Jake R. Pomperada, MAED-IT
// Program to compute the salary of an employee in a company.

namespace payroll_solver
{
    class payroll
    {
        static void Main(string[] args)
        {
            string emp_name,position,reply;
            int no_days_work = 0,n=0;
            double sss = 0, philhealth = 0, tax=0,pag_ibig=0, daily_rate=0;
            double total_deductions = 0, gross_pay = 0, net_pay = 0;

            
        do {
            Console.Clear();
            Console.Write("EMPLOYEE'S PAYROLL SYSTEM");
            Console.Write("\n\n");
            Console.Write("Enter Employee's Name       : ");
            emp_name = Console.ReadLine();
            Console.Write("Enter Employee's Position   : ");
            position = Console.ReadLine();
            Console.Write("Enter Number of Day's Work  : ");
            no_days_work = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter Daily Salary Rate     : ");
            daily_rate = Convert.ToDouble(Console.ReadLine());

            gross_pay = (no_days_work * daily_rate);

            Console.Write("\n\n");
            Console.WriteLine("Gross Pay       : Php {0:0.00}.",  gross_pay);
            Console.Write("\n\n");
            Console.Write("===== DEDUCTIONS =====");
            Console.Write("\n\n");
            Console.Write("Enter SSS Contribution            : ");
            sss = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter PAG-IBIG Contribution       : ");
            pag_ibig = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter PHILHEALTH Contribution     : ");
            philhealth = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter BIR TAX Contribution        : ");
            tax = Convert.ToDouble(Console.ReadLine());

            total_deductions = (sss + pag_ibig + philhealth + tax);

            net_pay = (gross_pay - total_deductions);

            Console.Write("\n\n");
            Console.WriteLine("Total Deductions      : Php {0:0.00}.", total_deductions);
            Console.Write("\n\n");
            Console.Write("===== DISPLAY RESULTS =====");
            Console.Write("\n\n");
            Console.WriteLine("Employee's Name       : {0}.", emp_name);
            Console.WriteLine("Empoyee's  Position   : {0}.", position);
            Console.WriteLine("Gross Pay             : Php {0:0.00}.", gross_pay);
            Console.WriteLine("Total Deductions      : Php {0:0.00}.", total_deductions);
            Console.Write("\n\n");
            Console.WriteLine("Net Pay               : Php {0:0.00}.", net_pay);
            Console.Write("\n\n");
            Console.Write("Do You Want To Continue? Y/N : ");
            reply = Console.ReadLine();

            if (reply == "y" || reply == "Y")
            {
                continue;
            }
            else if (reply == "n" || reply == "N")
            {
                Console.Write("\n\n");
                Console.Write("Thank You For Using This Software.");
                Console.Write("\n\n");
                break;
            }
           
        } while (n == 0);
          Console.ReadLine();
        } 
    }
}