Sunday, May 22, 2016

Odd and Even Numbers Using Java Spring Framework

A simple program that I wrote using Java Programming language and Spring Framework to check if the given number by the user is an Odd and Even Number.

 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


TestSpringProject.java

package org.gontuseries.springcore;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestSpringProject {

public static void main(String[] args) {
 @SuppressWarnings("resource")
ApplicationContext context = 
 new ClassPathXmlApplicationContext("SpringConfig.xml");
 
 Odd_Or_Even Odd_Or_EvenObj = (Odd_Or_Even) context.getBean("Odd_Or_Even_Bean");
    
 Odd_Or_EvenObj.checking();
}
}


SpringConfig.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
           
<bean id="Odd_Or_Even_Bean" class="org.gontuseries.springcore.Odd_Or_Even">
</bean>

</beans>

Odd_Or_Even.java

import java.util.Scanner;

public class Odd_Or_Even {
int number=0;
public void checking() {
 @SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
 System.out.println();
 System.out.println("Odd or Even Number Checker in Java Spring Framework");
 System.out.println("\n");
   
 System.out.print("Give a Number : ");
     number = in.nextInt();
     
     if ( number % 2 == 0 ) {
            System.out.println("\n");
            System.out.println("The number " + number + " is an even number.");
     }
         else {
        System.out.println("\n");
            System.out.println("The number " + number + " is odd number.");
}

 
 System.out.println("\n");
 System.out.println("End of Program");
 
}

}



List of Numbers Without Using a Loop in C++

A simple program that I  wrote in C++ that will list down  a  number from one to fifty without using a looping statement 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 mobile number here in the Philippines is 09173084360.




Sample Program Output


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");

}



Sum of Digits in C++

A simple program that I wrote using C++ language as my programming language that will ask the user to give a number and then our program will add the sum of digits in a given number by our user. The code is very 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

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

using namespace std;


int main()
{
   int number=0, process=0, sum = 0, remainder=0;

   cout <<"\n\n";
   cout <<"\t Sum of Digits in C++ ";
   cout <<"\n\n";
   cout <<"Kindly give a number : ";
   cin >> number;

   process = number;

   while (process != 0)
   {
      remainder = (process % 10);
      sum = sum  + remainder;
      process = (process / 10);
   }

   cout <<"\n\n";
   cout <<"The total sum of digits is " << sum << ".";
   cout <<"\n\n";
   cout <<"End of Program";
   cout <<"\n\n";
   system("pause");
}

Sum of Digits in C

A simple program that I wrote using C language as my programming language that will ask the user to give a number and then our program will add the sum of digits in a given number by our user. The code is very 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


#include <stdio.h>
#include <stdlib.h>

int main()
{
   int number=0, process=0, sum = 0, remainder=0;

   printf("\n\n");
   printf("\t Sum of Digits in C ");
   printf("\n\n");
   printf("Kindly give a number : ");
   scanf("%d", &number);

   process = number;

   while (process != 0)
   {
      remainder = (process % 10);
      sum = sum  + remainder;
      process = (process / 10);
   }

   printf("\n\n");
   printf("The total sum of digits is %d.", sum);
   printf("\n\n");
   printf("End of Program");
   printf("\n\n");
   system("pause");
}

Sum of Digits in JavaScript

A simple program that I wrote using JavaScript as my programming language that will ask the user to give a number and then our program will add the sum of digits in a given number by our user. The code is very 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

<!DOCTYPE html>  
<html>   
<head>  
<meta charset=utf-8 />  
<title>Sum of Digits in JavaScript</title>  
<style type="text/css">  
body {
    font-family:arial;
font-size:12;
font-weight:bold;
    background-color:lightgreen;
margin: 30px;
}
</style>   
</head>  
<body>  
<script>

function Sum_of_Digits() {

 var number = document.getElementById("number1").value;
            
  var str = number.toString();
  var sum = 0;

  for (var i = 0; i < str.length; i++) {
    sum += parseInt(str.charAt(i), 10);
  }
document.getElementById("result").innerHTML = sum;

}

</script>
<hr>
<h2>Sum of Digits in JavaScript </h2>
 <hr>

<form>  
Enter a number <input type="text" id="number1"  maxlength="10" size="10"><br>  
<br>
<input type="button" onClick="Sum_of_Digits()" Value="Ok" 
title="Click here to find the total sum of digits of a number." />  &nbsp;
</form>  <br>
<p>The total sum of digits is : 
<span id = "result"></span>  
</p>  
</body>  
</html>  


Sum of Digits in Python

A simple program that I wrote using Python as my programming language that will ask the user to give a number and then our program will add the sum of digits in a given number by our user. The code is very 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

def sum_digits(num):
  result = 0
  base = 10
  pos = 10
  while pos <= num*base:
    prev = pos/base
    result = result + int( (num % pos)/ prev)
    pos = pos*base
  return result

def my_program():
   print()
   print("SUM OF DIGITS IN PYTHON")
   print()
   number = int(input("Enter a Number : "))
   print()
   solve_me = sum_digits(number)
   print("The total sum of digits is " , solve_me, ".")
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("THANK YOU FOR USING THIS SOFTWARE")
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()




Sunday, May 15, 2016

Power of Given Number in C


This sample program will compute the power of a given number in C language. It will ask the user the base and exponents value of the number and then it will compute the power of the given number.

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

#include <stdio.h>
#include <stdlib.h>

int main()
{
  int base=0, exponent=0;
  long long int value=1;
  printf("Power of Given Number in C");
  printf("\n\n");
  printf("Give the Base Value     : ");
  scanf("%d",&base);
  printf("Give the Exponent Value : ");
  scanf("%d",&exponent);

  while (exponent != 0)
  {
      value *= base;
      --exponent;
  }
  printf("\n\n");
  printf("The result is %d.", value);
  printf("\n\n");
  printf("\t End of Program");
  printf("\n\n");
  system("pause");
}



Saturday, May 14, 2016

Fibonacci Number Sequence in JavaScript

A simple program that I wrote in JavaScript to accept a number from the user and then our program will generate the corresponding Fibonacci Number Sequence.

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

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title> Fibonacci Sequence in JavaScript</title>
<style>
body {
  font-family:arial;
  color:blue;
  font-size:18px;
  }
  
 input[type="text"] {
  display: block;
  margin: 0;
  width: 15%;
  font-family: arial;
  font-size: 18px;
  appearance: none;
  border-radius: 2px;
  box-shadow: 10px 10px 7px #888888;
}
input[type="text"]:focus {
  outline: none;
}

input[type=button] {
padding:12px 31px; 
background:yellow; border:10px;
cursor:pointer;
-webkit-border-radius: 12px;
box-shadow: 10px 10px 7px #888888;
border-radius: 5px; 
font-family: arial;
font-size: 18px;
}
</style>
</head>
<body bgcolor="lightgreen">
<script>
function start_fibonacci() {

   var num, first = 0, second = 1, next, c;
   var value_number = document.getElementById("UserInput").value
   var num = Number(value_number);

  for ( c = 0 ; c < num ; c++ )
   {
      if ( c <= 1 )
         next = c;
      else
      {
         next = first + second;
         first = second;
         second = next;
      }

 
document.getElementById('result').innerHTML +=  + next + "<br>";
 
}
   
}
function clear_now()
{
document.getElementById('result').innerHTML="";
document.getElementById('userInput').value="";
document.getElementById('userInput').focus();
}  
</script>
<b> Fibonacci Sequence in JavaScript </b> <br><br>
<form name="myform" action="">
<b>Give a Number </b><br><br>
<input type='text' id='UserInput' placeholder="enter number here" value='' size="5" required autofocus/>
<br><br>
<input type='button' onclick='start_fibonacci()' 
title="Click here to generated fibonacci sequence number." value='OK'/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type='button' onclick='clear_now()' title="Click here to clear the textbox." value='CLEAR'/>
</form>
<br><br>
</body>
Fibonacci Sequence Result 
<br><br>
<div id = "result"></div>  
</html>



Palindrome of Number in JavaScript

This sample program will ask the user to give a number and then our program will check and determine whether the given number by the user is a Palindrome or Not a Palindrome. I wrote this program using JavaScript.

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


<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Palindrome of Number in JavaScript</title>
<style>
body {
  font-family:arial;
  color:blue;
  font-size:18px;
  }
  
 input[type="text"] {
  display: block;
  margin: 0;
  width: 15%;
  font-family: arial;
  font-size: 18px;
  appearance: none;
  border-radius: 2px;
  box-shadow: 10px 10px 7px #888888;
}
input[type="text"]:focus {
  outline: none;
}

input[type=button] {
padding:12px 31px; 
background:yellow; border:10px;
cursor:pointer;
-webkit-border-radius: 12px;
box-shadow: 10px 10px 7px #888888;
border-radius: 5px; 
font-family: arial;
font-size: 18px;
}
</style>
</head>
<body bgcolor="lightgreen">
<script>
function start_palindrome() {
   var revStr = "";
   var str = document.getElementById("UserInput").value;
   var i = str.length;

     for(var j=i; j>=0; j--) {
         revStr = revStr+str.charAt(j);
       }
if(str == revStr) {
    document.getElementById("result").innerHTML = "The Number " + str + " is Palindrome.";
   } 
 else {
     document.getElementById("result").innerHTML = "The Number " + str + " is Not a Palindrome.";
     }
}
function clear_now()
{
document.getElementById('result').innerHTML="";
document.getElementById('userInput').value="";
document.getElementById('userInput').focus();
}  
</script>

<b> Palindrome of Number in JavaScript </b> <br><br>
<form name="myform" action="">
<b>Give a Number </b><br><br>
<input type='text' id='UserInput' placeholder="enter number here" value='' size="5" required autofocus/>
<br><br>
<input type='button' onclick='start_palindrome()' 
title="Click here to findout if the number in a palindrome or not." value='OK'/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type='button' onclick='clear_now()' title="Click here to clear the textbox." value='CLEAR'/>
</form>
<br><br>
</body>
<div id = "result"></div>  
</html>