Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

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:

Tuesday, September 30, 2014

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




 }

}

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