Thursday, October 20, 2016

Year Level Checker in C#

Hi there in this article I would like to share with you our simple program will ask the user to give the year level where the student is belong to like freshmen, sophomore, juniors and seniors. Using if else statement in C#. I also make sure that if the user gives a letter or special character our program will not crash and inform the user to provide valid input value like a number. I hope you will find my work useful in learning C#  programming. 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 Outpu




Program Listing


using System;

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

namespace year_level
{
    class year_level
    {
        static void Main(string[] args)
        {
            
            string input;
            int year = 0;
            bool result = false;
    
                while (result == false)
                {
                    Console.Write("\n\n");
                    Console.Write("Year Level Checker ");
                    Console.Write("\n\n");
                    Console.Write("Enter Your Year Level : ");
                    input = Console.ReadLine();
                    result = int.TryParse(input, out year);
                    if (result == false)
                    {
                        Console.Write("\n");
                        Console.Write("Please Enter Numbers Only.");
                    }
                    else if (year == 1)
                    {
                        Console.Write("\n\n");
                        Console.Write("You are belong to Freshment.");
                        break;
                    }
                    else if (year == 2)
                    {
                        Console.Write("\n\n");
                        Console.Write("You are belong to Sophomore.");
                        break;
                    }
                    else if (year == 3)
                    {
                        Console.Write("\n\n");
                        Console.Write("You are belong to Juniors.");
                        break;
                    }
                    else if (year == 4)
                    {
                        Console.Write("\n\n");
                        Console.Write("You are belong to Senior.");
                        break;
                    }
                    else
                    {
                        Console.Write("\n\n");
                        Console.Write("Invalid Year Level. Try Again.");
                        result = false;
                        
                    }

                }
                         
                    Console.Write("\n\n");
                    Console.Write("Thank You For Using This Software.");
                    Console.Write("\n\n");
                    Console.ReadLine();
        }
    }
}

String of Arrays in C++

Here is a sample program that I wrote a long time ago to show how to display a series of names of countries around the world using two dimensional array, strings and character in C++. The code is very short and easy to understand.

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;


int main()

{

char Country[6][15] = { "America", "Japan", "Zimbabwe",

                     "Sri Lanka", "Philippines",
                      "El Salvador" };

cout << "\t\t ARRAY OF STRINGS 1.0";
cout << "\n";
cout << "\n\tCreated By: Mr. Jake R. Pomperada, MAED-IT";
cout << "\n\nLIST OF COUNTRY NAMES";
    cout << "\n\n";
for(int i = 0; i < 6; ++i)

cout << "\nCountry " << i + 1 << ": " << Country[i];



cout << "\n\n";

return 0;

}

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