Posts

Showing posts from August, 2017

Computer Graphics Project "Planet Orbit" Source Code with Glut OpenGL

Image
Hello there !!!  This time I will post a project in the past. It is about rotation and applied to make earth orbital with moon and sun. As reminder, for you who haven’t install glut you can download it in here and follow the instruction I uploaded too. You can download this orbital project in here too. The image above is the result of orbital project. Here is the source code for this project. #include <windows.h> #include <stdlib.h> #include <GL/glut.h> #include <math.h> void myinit() { glClearColor(0.0, 0.0, 0.0, 1.0); glColor3f(1.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-400.0, 400.0, -400.0, 400.0,-400.0,400.0); glMatrixMode(GL_MODELVIEW); glShadeModel(GL_FLAT); glEnable(GL_DEPTH_TEST); } float putaransatu, putarandua = 0; typedef struct{ float x,y; } point2D_t; void drawDot(int x,int y){ glBegin(GL_POINTS); glVertex2i(x,y); glEnd(); } /*void bintang(void) { static int tick=0; static poi

Computer Graphics Project "MINION" Source Code with Glut OpenGL

Image
Hello !!! This time I post about computer graphics again. And yes, I will share a project which mainly used rotation and a little bit morphing. You can download this project here ( Download here to download glut and follow the instruction ) .The character used in this project is well known. Well here’s the depiction of this project. Minion !!! The eyes will rotate. And it’s smile will move up and down which give you a creepy smile hahaha.  So here’s the source code for this project : #include <stdio.h> #include <math.h> #include <GL/glut.h> #ifndef M_PI #define M_PI 3.141592653589793 #endif typedef struct { float x; float y; } point2D_t; typedef struct { float r; float g; float b; } color_t; ////////////// OpenGL drawShape Functions ver 1 ///////////////// void setColor(float red,float green,float blue) { glColor3f(red, green, blue); } void setColor(color_t col) { glColor3f(col.r, col.g, col.b); } void drawDot(float x,float y) { glB

Computer Graphics using GLUT projects Source Code : Tiles Pattern

Image
Hello !!! Today I want to share my past project in computer graphics using Glut. For you who still do not have glut for C library, you can download it in here . I also give instruction how to installed it in your project here . And here are the projects for this tiles pattern.Actually, I made many of them in the past. But I’ll post them on by one in the future. This project of mine is tiles pattern. Most of it contains polygon lines. The result is just like  picture below : So You know computer graphics is such an existence which make you drawing with code instead of pencil or pen :p. So yeah the listing must be so long since this project used procedural programming. here are the source code for this project : // Created by: Dean Nicholls // Date: 18th June 2010 // Created For: http://www.levelbylevel.com // // This is a small OpenGL application which will display a // blue sphere on a black background. // // This Program was created to acompany the tutorial // for se

Conditional Statement Introduction

Image
Conditional is an essential part in programming. You can do many things with it. In the past, I read a book about basic programming. The author said that most of programs written from various language are only contain  repetition and conditional. So this time I’ll give a solution from 30 days challenge code from hackerrank . This is really a simple program about selection of odd and even number. Okay, the image above is the condition which we should implement in listing code. It’s quite easy right. First,  you input integer number (not decimal). Remember the constraint is number you input is from 1 to 100. .Then you start with selection whether the number is odd or not. In mathematic we all know that odd number is an integer number that can not be divided by 2. So if we operate it with modulo operation, odd number will result 1. Odd number should print “Weird”. Back again, if the number is not odd then do a selection again for even number. The range already mention in t

Simple Cashier Program Source Code in Java

Image
Now we are already in Day 2 in 30 day code challenge from hackerrank . This task will test you some uses of operators. As you know mathematic operations have to use several operator like “+” for sum, “-” for subtraction, “*” for multiplication, “/” for division, “%” for modulo operation, “( )” for do an operation which inside of it first, and so on. In here, you will make a program like a cashier. Given a meal cost, tip percentage, and  tax percentage will be resulted a total amount of money customer must be paid. Image below show you how the program should be. After understanding the algorithm of program, then here the solution : import java.util.*; import java.math.*; public class Arithmetic { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double mealCost = scan.nextDouble(); // original meal price int tipPercent = scan.nextInt(); // tip percentage int taxPercent = scan.nextInt(); // tax percen

A Month of Coding Challenges with Java: Day 1 - Data Type

Image
After we step  from hello word, then we will forward with Day 1. This challenge will remind you the use of data type in programming language. Since I will java then data type in here will follow java programming rule. But at least, most of programming language have the similarity in data type. The purpose of this task is to make operation from variable which have same data type.. First variable s,i and d are already declared and initialized. Your job is to declare new variable which have similar data type. Then use + operator for each corresponded data type variables. Here listing program for this task. import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { int i = 4; double d = 4.0; String s = "HackerRank "; Scanner scan = new Scanner(System.in); /* Declare second integer, double, and String variabl

A Month of Coding Challenges with Java: Day 0 - Hello World

Image
Hello world ! as I said in previous post, for the future post I will try to make solutions from challenges website. As for beginning to advanced we will start from 30 Days of Code Challenges . If you already registered in HackerRank you will asked if you want enroll this challenge. Well the purpose is to give you basic foundation. If you already finished one challenge you must wait for 24 hour to unlock the next challenge. If you tired of waiting you can enroll another challenge. There are so many of them, so you can choose as you like. So lets begin. We will start from Day 0 : Hello World. Most of programming tutorial will start to run hello world program. The purpose is to make sure that component of the said programming language is already installed properly in your PC. Besides that it gives you a nice introduction to that language. Imagine a toddler starts to learn speak from difficult word, I wonder how the outcome :D. So in the picture above the “Try Again” button used

5 Website for Coding Challenge

Image
Hello world ! This time I want to tell you something about future post. You may to comment it as you wish and I’d appreciate it so much :). You know we as programmer some time need to improve our skill to write a code and  make better algorithm for better program performance. There are various ways to improve it. You can take many projects to enhance your skill. However sometime projects do not come continuously to us. So one of that many ways is doing challenges given by someone else. In this broad sea of internet, there are many sites which provide challenges to fellow programming. They even given challenges in different level too. So for you who just step in this realm you can take beginner level. So, I will give some examples of that challenge site, here we go. HackerRank From the site, they explained it’s existency that HackerRank is a place where developers from everywhere throughout the world meet up to take care of issues in an extensive variety of Computer Sci

Prime Number Sequence Program Source Code in Java

Image
Hello world ! In the past we have posted prime number sequence program source code in C. This time we'd like to share the same program but in Java. Before that, we have to know what is prime number. In mathematics, prime numbers are native numbers greater than 1, whose divisor is 1 and the number itself. 2 and 3 are primes. 4 is not a prime number because 4 can be divided by 2. package Prime; import java.util.Scanner; public class Prime { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.print(" Prime number limit : "); int num = in.nextInt(), ce, i, j, tot = 0, tamp[] = new int[4444]; for(i=2; i<=num; i++){ ce = 0; for(j=2; j<=i; j++) if(i%j == 0) ce++; if(ce == 1){ tamp[tot] = i; tot++;} } for(i=0; i<tot; i++) System.out.print(" " + tamp[i]); } } The result of listing program above is like this : If you have any question regarding this post, please leave a comment below. Pl

Fibonacci Sequence Source Code in Java

Image
Hello World ! This time we'd like to share fibonacci sequence source in java. But firstly, we would like to give you short explanation about the sequence.  In mathematics, Fibonacci numbers are sequences that are recursively defined as follows: This sequence starts from 0 and 1, then the next number is obtained by adding two consecutive numbers. In short the name of sequence must have a pattern to make a series of number isn't it ? well if you want to know the theory about fibonacci just read this page (it is much easier to understand than wikipedia :p). Then this is source code of program to display fibonacci sequence  : import java.util.Scanner; public class Fibonacci { public static void main(String args[]) { int a = 1, b = 0, c, n, i = 0; System.out.println("Count Fibonanci Numbers!\n " + "Input number of series = "); Scanner in = new Scanner(System.in); n = in.nextInt(); while(i < n){ c = a + b; a = b; b = c

Determine Leap Year Program using Java

Image
As we know  leap year is a year that adds a day in order to adjust the calendar to the astronomical year. In a year does not exactly consist of 365 days, but 365 days 5 hours 48 minutes 45.1814 seconds. If this is ignored, then every 4 years will be short of almost 1 day (exactly 23 hours 15 minutes 0.7256 seconds). So to compensate for this, every 4 years (4 divided years), given an extra day: February 29th. But since 5 hours 48 minutes 45.1814 seconds is less than 6 hours, then the years that can be divided 100 (as in 1900), not leap years, except can be divided by 400 (as in 2000). you can find more information regarding leap year in here . So, we shared a program to determine whether user input is leap year or not. import java.util.Scanner; public class Kabisat{ public static void main(String args[]) { int year; Boolean cek = new Boolean(false); System.out.println(" Input year :"); Scanner in = new Scanner(System.in); year = in.nextInt(); if(year &

Java Program Source Code for Converting a value from Celsius to Fahrenheit or Vice Versa

Image
Hello world ! This time we'd like to share you java source code for program to convert a value from Celsius to Fahrenheit or vice versa. import java.util.Scanner; public class Konversi { public static void main(String[] arguments) { Scanner in2; double res = 0; System.out.println("Please select,\n1. C to F\n2. F to C"); Scanner in1 = new Scanner(System.in); System.out.print("= "); switch(in1.nextInt()){ case 1: System.out.println("C = "); in2 = new Scanner(System.in); res = in2.nextInt() * 9 / 5 + 32; break; case 2: System.out.println("F = "); in2 = new Scanner(System.in); res = (in2.nextInt() - 32) * 5 / 9; break; default: System.err.println ("Unrecognized option"); break; } System.out.println("\n Result is " + res); }} Here's how the result look like : The program will ask you what conversion you world like to choose. If you sel

Java Program : Calculate The Area and Circumference of Circle

Image
Hello world ! This time we'd like to share you how to calculate the area and circumference of a circle. import java.util.Scanner; import java.util.Scanner; import java.lang.Math.*; public class LuasKeliling { public static void main(String[] arguments) { Scanner in2; double res = 0; System.out.println("Please select,\n1. to define circumference of circle\n2. to define area of circle"); Scanner in1 = new Scanner(System.in); System.out.print("= "); switch(in1.nextInt()){ case 1: in2 = new Scanner(System.in); System.out.println(" Radius = "); res = Math.PI * in2.nextInt() * 2; break; case 2: in2 = new Scanner(System.in); System.out.println(" Radius = "); res = Math.PI * Math.pow(in2.nextInt(), 2); break; default: System.err.println ("Unrecognized option"); break; } System.out.println("\n Result is " + res); } } The result of listing program abo

Installation and Basic Configuration of Apache Web Server

Image
Hello world, previously we post the definition of web server and how it works. So here how to configure web server using apache. Install apache2 package Check using nmap Check the web server using a browser http://localhost . If it appears like this then it works Installing PHP5 Perform testing on php5 If it looks like the picture above then work and type http: //localhost/index.php. If the result looks like the picture below then it works Install mysql At the time of the installation process is told to go to the root is useful if we need to create a database. Test Mysql service using nmap

What is Web Server ?

Image
A Web server is a software that provides access services to users via HTTP or HTTPS communication protocols over files contained on a website, users use certain applications in the form of web browsers in making requests. The results of requests for web pages are generally in the form of HTML documents. The Web began in 1989, Tim Berners-Lee through CERN (European Organization for Nuclear Research) proposed a project aimed at facilitating the exchange of information among researchers using a hypertext system. As a result of the implementation of this project, in 1990 Berners-Lee wrote two computer programs: The world's first web server, which came to be known as CERN httpd, which runs on the NeXTSTEP operating system. A browser he named WorldWideWeb; In 1994, Tim Berners-Lee decided to standardize the World Wide Web Consortium (W3C) organization to organize advanced developments on other related technologies (HTTP, HTML, etc.) through the standardization process.