Sunday, October 12, 2014


Simple example of Movie Booking System use Java Application . Database use is MySQL .
Have 5 table which is : Customer , Movie , Admin , Hall , Booking .

Role for Customer/User:
  • Login
  • Register
  • Choose Movie
  • Choose Date and Time
  • Choose Seats
  • View Booking Details
  • View Movie Details
Role for Admin:
  • Login
  • Add New Movie
  • View Movie Details

Incoming Search:

Wednesday, October 1, 2014

Hide Your Name at Blogspot


1st Step : Go to Your Dashboard and click your Blog name

2nd Step : Go to Layout

3rd Step : Find a blog post box like a picture below . and click EDIT



4th Step : Unchecked the Posted by check box like the picture below



5th Step : Click Save button . DONE 


IF the author name still show up .. GO TO TEMPLATE , then EDIT HTML ..

Search for  <data:post.author/> at the code line ... Remove all the <data:post.author/>


How To Remove the Powered by Blogger text from your blogspot .



First Step : Go to Your Blog Dashboard. then click your blog name

2nd Step : Go to Template

3rd Step : Click a Button Name Edit HTML

4th Step : Search For </head> at the code line 

5th: Add this code above the </head>

<style type="text/css">

    #Attribution1{display:none;}

</style>

6th Step : Refresh your Blog . DONE


Tuesday, September 30, 2014

-EXAMPLE COMMAND-

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;

To see database's field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value "whatever".

mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

Show all records containing the name "Bob" AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

Show all records starting with the letters 'bob' AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];


To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';

Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = 'whatever';

Update database permissions/privilages.

mysql> flush privileges;

Delete a column.

mysql> alter table [table name] drop column [column name];

Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);

Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.

mysql> alter table [table name] drop index [colmn name];

Create table with default and constraint.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');

Add column in between after other column.


mysql> ALTER TABLE contacts ADD email VARCHAR(60) AFTER name;

Add column the be the first column.

mysql> ALTER TABLE contacts ADD email VARCHAR(60) FIRST;

Add primary key.

mysql> alter table employees add primary key (empid);

Insert multiple value.

INSERT INTO [table]
( [field1], [field2], [field3] ) VALUES
( '[value1.1]', '[value1.2]', '[value1.3]' ),
( '[value2.1]', '[value2.2]', '[value2.3]' ),
( '[value3.1]', '[value3.2]', '[value3.3]' );

Change column name(date to dateofbirth).

mysql> alter table employees change date dateofbirth date;

Select / display Minumun or lowest
(salary =columnname,minsalary=newcolumn name,employee=table) .

mysql> select min(salary)as MinSalary from employee;

Select / display maximum or highest.

mysql> select max(salary)as MaxSalary from employee;

Select / display average.

mysql> SELECT avg( mark ) FROM student;

Display unique or no repeat value.

mysql> SELECT distinct [column1], [column2]
FROM [table];


REFERENCES:




MySQL uses all the standard ANSI SQL numeric data types, so if you're coming to MySQL from a different database system, these definitions will look familiar to you. The following list shows the common numeric data types and their descriptions.

INT - A normal-sized integer that can be signed or unsigned. If signed, the allowable range is from -2147483648 to 2147483647. If unsigned, the allowable range is from 0 to 4294967295. You can specify a width of up to 11 digits.

TINYINT - A very small integer that can be signed or unsigned. If signed, the allowable range is from -128 to 127. If unsigned, the allowable range is from 0 to 255. You can specify a width of up to 4 digits.

SMALLINT - A small integer that can be signed or unsigned. If signed, the allowable range is from -32768 to 32767. If unsigned, the allowable range is from 0 to 65535. You can specify a width of up to 5 digits.

MEDIUMINT - A medium-sized integer that can be signed or unsigned. If signed, the allowable range is from -8388608 to 8388607. If unsigned, the allowable range is from 0 to 16777215. You can specify a width of up to 9 digits.

BIGINT - A large integer that can be signed or unsigned. If signed, the allowable range is from -9223372036854775808 to 9223372036854775807. If unsigned, the allowable range is from 0 to 18446744073709551615. You can specify a width of up to 11 digits.

FLOAT(M,D) - A floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D). This is not required and will default to 10,2, where 2 is the number of decimals and 10 is the total number of digits (including decimals). Decimal precision can go to 24 places for a FLOAT.

DOUBLE(M,D) - A double precision floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D). This is not required and will default to 16,4, where 4 is the number of decimals. Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym for DOUBLE.

DECIMAL(M,D) - An unpacked floating-point number that cannot be unsigned. In unpacked decimals, each decimal corresponds to one byte. Defining the display length (M) and the number of decimals (D) is required. NUMERIC is a synonym for DECIMAL.


Date and Time Types:

The MySQL date and time datatypes are:

DATE - A date in YYYY-MM-DD format, between 1000-01-01 and 9999-12-31. For example, December 30th, 1973 would be stored as 1973-12-30.

DATETIME - A date and time combination in YYYY-MM-DD HH:MM:SS format, between 1000-01-01 00:00:00 and 9999-12-31 23:59:59. For example, 3:30 in the afternoon on December 30th, 1973 would be stored as 1973-12-30 15:30:00.

TIMESTAMP - A timestamp between midnight, January 1, 1970 and sometime in 2037. This looks like the previous DATETIME format, only without the hyphens between numbers; 3:30 in the afternoon on December 30th, 1973 would be stored as 19731230153000 ( YYYYMMDDHHMMSS ).

TIME - Stores the time in HH:MM:SS format.

YEAR(M) - Stores a year in 2-digit or 4-digit format. If the length is specified as 2 (for example YEAR(2)), YEAR can be 1970 to 2069 (70 to 69). If the length is specified as 4, YEAR can be 1901 to 2155. The default length is 4.

String Types:

Although numeric and date types are fun, most data you'll store will be in string format. This list describes the common string datatypes in MySQL.

CHAR(M) - A fixed-length string between 1 and 255 characters in length (for example CHAR(5)), right-padded with spaces to the specified length when stored. Defining a length is not required, but the default is 1.

VARCHAR(M) - A variable-length string between 1 and 255 characters in length; for example VARCHAR(25). You must define a length when creating a VARCHAR field.

BLOB or TEXT - A field with a maximum length of 65535 characters. BLOBs are "Binary Large Objects" and are used to store large amounts of binary data, such as images or other types of files. Fields defined as TEXT also hold large amounts of data; the difference between the two is that sorts and comparisons on stored data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You do not specify a length with BLOB or TEXT.

TINYBLOB or TINYTEXT - A BLOB or TEXT column with a maximum length of 255 characters. You do not specify a length with TINYBLOB or TINYTEXT.

MEDIUMBLOB or MEDIUMTEXT - A BLOB or TEXT column with a maximum length of 16777215 characters. You do not specify a length with MEDIUMBLOB or MEDIUMTEXT.

LONGBLOB or LONGTEXT - A BLOB or TEXT column with a maximum length of 4294967295 characters. You do not specify a length with LONGBLOB or LONGTEXT.

ENUM - An enumeration, which is a fancy term for list. When defining an ENUM, you are creating a list of items from which the value must be selected (or it can be NULL). For example, if you wanted your field to contain "A" or "B" or "C", you would define your ENUM as ENUM ('A', 'B', 'C') and only those values (or NULL) could ever populate that field.
The example how to calculate Average Using C programming:

Example the question ask you to display the average of mark key in by the user/student and based on the input display the grade, and the average mark :-


    average      grade
 At least 80       A
 60 – 79            B
 50 – 59            C
Less than 50      F






 Source Code:
#include <stdio.h>

int main(){
int i;
float num[3],
sum=0.0,average;

printf("--------------------------\n ");
printf("  STUDENT DETAILS \n");
printf("--------------------------- \n\n");


for(i=0; i<3 ; i++)
   {
        printf("Enter mark: %d :",i+1);
        scanf("%f",&num[i]);
        sum+=num[i]; }

        average=sum/3;

        printf("\nAverage = %.2f",average);
        if(average >= 80)
{
printf("\nGrade = A\n");
}
else if(average >= 60 && average <= 79)
        {
            printf("\nGrade = B\n");
        }
        else if(average >=50 && average <=59)
        {
            printf("\nGrade = C\n");
        }
        else
        {
            printf("\nGrade = F\n");
        }

        return 0;
    }
Example the question ask you to write a program to determine the number that user enter which is positive,negative or Zero number...

The program below will ask the user to enter one number, and the program will determine the number whether the number is positive, negative or zero. and the program will ask the user whether they want to continue or stop the program.

Sample Output:

Source code:

import java.util.Scanner;
public class posnegnum
{
 public static void main (String [] arg)
 {
 Scanner input = new Scanner(System.in);

 int j = 0;

 do
  {
   System.out.println("Enter a number:");
   double n = input.nextDouble();
 
   if( n>0 )
    System.out.println(n +" is a positive number");
   else if( n<0 )
    System.out.println(n +" is a negative number");
   else
    System.out.println(n +" is a zero number");
   
    j++;
   
    System.out.println("do you want to continue? (enter 1 to continue 0 to stop) " );
    j = input.nextInt();
   
  }while(j == 1);
 
 }

}

This program is Meter to Inches and Meter to Feet Converter , first, user must choose which converter they want. After that, user will be ask to enter the distance (in meter) that they want to convert to Inches or Feet. to stop this program user must enter 3.

Sample output:



Sample Source Code:

import java.util.Scanner;

 public class converter
  {
   public static void main(String[] args)
   {


    Scanner input = new Scanner(System.in);

    display_menu(); //call method to display menu

    System.out.print("\nEnter your choice:");
    int choice = input.nextInt();


    while(choice!=3)
    {
     if(choice>3||choice<1)
     {
      System.out.println("u enter invalid number");
     }
     else
     {

      System.out.print("Enter the distance in meters:");
     double meter = input.nextDouble(); //input from user for meters

     switch(choice)
      {
       case 1 : double answer = showInches(meter);  //call method to show inches
         System.out.println(+ meter+" meters is " +answer+ " inches"); //display answer
         break;

       case 2 : double answers = showFeet(meter);  //call method to show feet
         System.out.println(+meter+" meters is "+answers+" feet"); //display answer
         break;
      }
     }

     display_menu();   //call method to display menu

     System.out.print("\nEnter your choice:");
     choice = input.nextInt();  //Enter choice again

    }




    System.out.println("Thank you!");


   }

   public static double showInches(double meter)
   {
    double inches= meter * 39.37;

    return (inches); //formula to get inches
   }

   public static double showFeet(double meter)
   {
    double feet =meter * 3.281;
    return (feet); //formula to get feet
   }
   public static void display_menu()
   {
    System.out.println("\nConversion Program");
    System.out.println("1. Convert to inches");
    System.out.println("2. Convert to feet");
    System.out.println("3. Exit");
   }


}
This simple program will ask user to enter their mile driven and the gallon of gas, and the program will calculate the MPG.


Sample Output:


Sample Source Code:

public class MPG
{

 public static void main(String [] args)
 {
  Scanner input = new Scanner(System.in);

  System.out.print("Enter Mile driven: ");
  double mile = input.nextDouble();

  System.out.print("Enter Gallon of gas: ");
  double gallon = input.nextDouble();

  double mpg = mile / gallon;


  System.out.print("your mile/gallon "+ mpg);




 }

}


A friend function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class.

Even though the prototypes for friend functions appear in the class definition.

  •  friends are not member functions. 
  •  friend can be a function, function template, or member function, or a class or class template.

Program bellow is the example how to use Friend Function to do addition,Subtraction and find a Max Number between two number using C++ Programming.

explanation: User need to key in two number, x number and y number, and the program will do the calculation for addition and subtraction and also determine the highest number between x and y.

Sample Output:


Sample Source Code:

#include<iostream>
#include<string>

using namespace std;

class NUMBERS
{
      private:
              int x,y;
      public:

            NUMBERS():x(0),y(0){ }

            NUMBERS(NUMBERS &nm)
            {
             x=nm.x;
             y=nm.y;
            }

            void setinput(int a,int b)
            {

              x=a;
              y=b;

              }

              friend int addition(NUMBERS obj);
              friend int subtract(NUMBERS obj);
              friend int max_min(NUMBERS obj);

};

int addition(NUMBERS obj)
{
    return obj.x + obj.y;
}
int subtract(NUMBERS obj)
{
    return obj.x - obj.y;
}
int max_min(NUMBERS obj)
{
    if(obj.x > obj.y)
    {
    return obj.x;
    }
    else
    {
    return obj.y;
    }
};

int main()
{
    NUMBERS object;
    int a,b;

    cout<<"enter x : ";
    cin>>a;
    cout<<"enter y : ";
    cin>>b;

    object.setinput(a,b);

    addition(object);
    subtract(object);
    max_min(object);

    cout<<"\naddiction ="<<addition(object)<<endl;
    cout<<"substraction ="<<subtract(object)<<endl;
    cout<<"max_min ="<<max_min(object)<<endl;


           system("pause");
           return 0;
}

Calculate the highest, lowest and average mark key in by user.

This is the example to calculate the highest, lowest and average mark key in by user.
this program also count the number of student who get A,B,C,D or E from
the information key in by the user.

Sample Output:

Source code:

#include <iostream>
using namespace std;
int main(){

cout<< "\nStatistic of Class Performance\n\n";

int markA = 0,markB = 0,markC = 0,markD = 0,markE = 0;

int max = 0, min = 0;

double num[10],sum=0.0,average;



   for(int i=0; i<10 ; i++)
   {
        cout<<"\tEnter mark student "<<i+1<<" : ";
        cin>>num[i];

        if(num[i] >= 80 && num[i] <= 100)
        {
            markA = markA +1 ;
        }
        else if(num[i] >= 70 && num[i] <= 79)
        {
            markB = markB+1;
        }
        else if(num[i] >=50 && num[i] <=69)
        {
            markC = markC+1;
        }
        else if(num[i] >=40 && num[i] <= 49)
        {
            markD= markD+1;
        }
        else
        {
           markE= markE+1;
        }

        sum+=num[i];

   }

        max = num[0];
        min = num[0];

    for(int i=0; i<10 ; i++)
   {

        if(num[i]>max)
        {
            max = num[i];
        }
        else
        {
           max = max;
        }

        if(num[i]<min)
        {
            min = num[i];
        }
        else
        {
           min = min;
        }

   }
        cout<<endl<<"\tGrade"<<"\tThe Number Of Students"<<endl;
        cout<<"\tA\t"<<markA<<endl;
        cout<<"\tB\t"<<markB<<endl;
        cout<<"\tC\t"<<markC<<endl;
        cout<<"\tD\t"<<markD<<endl;
        cout<<"\tE\t"<<markE<<endl;

    /* Tamat Display */

        cout<<endl<<"\tThe Highest mark : "<<max<<endl;
        cout<<"\tThe Lowest mark : "<<min<<endl;

        average=sum/30;

        cout<<"\tThe Average mark : "<<average<<endl;

        return 0;

    }


Monday, September 29, 2014

Example the question will ask the user to enter integer and the program will determine the number is ODD or EVEN.

the program below will ask the user the enter one number, and the program will determine the number is odd or even. IF the user is enter odd number the program will send output "FALSE". The output will be true if and only if the user key in the EVEN number. The Programm will stop if the user ENTER 0 (Zero) .

example EVEN Number : 2,4,6,8 ....
example ODD Number: 1,3,5,7 ....

Sample Output:



Sample Source code:

import java.util.Scanner;

public class Q1
{
 public static void main(String [] args)
 {
  Scanner input = new Scanner(System.in);



  System.out.println("enter integer : ");
   int integer = new Scanner(System.in).nextInt();

  int select ;

  while(integer !=0){




   if(integer %2 == 0)
   {
    System.out.println(integer +  " is a even number? true ");
   }

   else
   {
    System.out.println(integer + " is even number? false ");
   }

   System.out.println("enter integer : ");
   integer = new Scanner(System.in).nextInt();


  }
 }


}

Zul Ameen Blog © 2013 | Powered by Blogger | Blogger Template by DesignCart.org