Thursday, February 16, 2017

java program to Book a show at different movie theaters available


package javaclass;

import java.util.Scanner;

class BookMyshow {

    private String move_name;
    private String thetre_name;
   
    private int cost;

    void movies() {
       
        System.out.println("the movies available are");
        System.out.println(" 1.shreak -------- Rs.40 \n 2.stuart little - Rs.50 \n 3.game movie ---- Rs.60 \n 4.fun movie ----- Rs.70 ");
       
       
    }

}

class thea extends BookMyshow {
private int no_f_tickets;
    void th() {
        System.out.println("*******the theaters available are******* \n 1.karunya th \n 2.anna th");
        int k;
        int an;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println("*******karunya theater*******");
            System.out.println("*******select a movie*******");
            System.out.println("movie available are \n 1.shreak \n 2.stuart little ");
            Scanner a = new Scanner(System.in);
            int o = a.nextInt();
            if (o == 1) {
                System.out.println("shreak movie @ kaurnya theater");
                System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=40*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- karunya theater");
                    System.out.println("movie --------------------- shreak");
                    System.out.println("cost ---------------------- Rs."+amount);
                    System.out.println("******************************************************");
                }

            }
            if (o == 2) {
                System.out.println("stuart little @karunya theater");
                 System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=50*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- karunya theater");
                    System.out.println("movie --------------------- staurt little");
                    System.out.println("cost ---------------------- Rs"+amount);
                    System.out.println("******************************************************");
                }

            }

        }
        if (n == 2) {
            System.out.println("*******anna theater*******");
            System.out.println("*******select a movie*******");
            System.out.println("movie available are \n 3.game movie \n 4.fun movie");
            Scanner b = new Scanner(System.in);
            int p = b.nextInt();
            Scanner a = new Scanner(System.in);
            int o = a.nextInt();
            if (o == 1) {
                System.out.println("game movie @ anna theater");
                 System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=60*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- anna theater");
                    System.out.println("movie --------------------- game movie");
                    System.out.println("cost ---------------------- Rs."+amount);
                    System.out.println("******************************************************");
                }

            }
            if (o == 2) {
                System.out.println("fun little @anna theater");
                 System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=70*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- anna theater");
                    System.out.println("movie --------------------- fun movie");
                    System.out.println("cost ---------------------- Rs."+amount);
                    System.out.println("******************************************************");
                }

            }
        }

    }
}

public class labfr {

    public static void main(String[] args) {
        BookMyshow ob = new BookMyshow();

        BookMyshow[] moviename = new BookMyshow[2];
        moviename[0] = ob;
        thea a = new thea();
        moviename[1] = a;

        System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
        System.out.println("---------1.list of movies and their prices--------- \n-------2.acces and book tickets through theaters---");

        System.out.println("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        Scanner d = new Scanner(System.in);
        int h = d.nextInt();
        switch (h) {
            case 1: {
                ob.movies();
                break;
            }
            case 2: {
             
                a.th();
            }
        }

    }

}

Saturday, February 11, 2017

sorting and displaying largest and smallest number- using java

import java.util.*;

public class labfour {

    public static void main(String a[]) {
        int v[] = new int[5];
        System.out.println("enter any five elements of the array");
        Scanner sc = new Scanner(System.in);
        v[0] = sc.nextInt();
        Scanner l = new Scanner(System.in);
        v[1] = l.nextInt();
        Scanner s = new Scanner(System.in);
        v[2] = s.nextInt();
        Scanner c = new Scanner(System.in);
        v[3] = c.nextInt();
        Scanner g = new Scanner(System.in);
        v[4] = g.nextInt();

        System.out.println("sorting the above array");
        for (int i = 0; i < v.length; i++) {
            for (int j = i + 1; j < v.length; j++) {
                if (v[i] > v[j]) {
                    int temp = v[i];
                    v[i] = v[j];
                    v[j] = temp;

                }

            }
            System.out.println(v[i]);

        }

        System.out.println("the smallest number is " + v[0]);
        System.out.println("the largest number is " + v[4]);

    }

}
output:

movie ticket booking - using java program

import java.util.Scanner;

class BookMyshow {

    private String move_name;
    private String thetre_name;
 
    private int cost;

    void movies() {
     
        System.out.println("the movies available are");
        System.out.println(" 1.shreak -------- Rs.40 \n 2.stuart little - Rs.50 \n 3.game movie ---- Rs.60 \n 4.fun movie ----- Rs.70 ");
     
     
    }

}

class thea extends BookMyshow {
private int no_f_tickets;
    void th() {
        System.out.println("*******the theaters available are******* \n 1.karunya th \n 2.anna th");
        int k;
        int an;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println("*******karunya theater*******");
            System.out.println("*******select a movie*******");
            System.out.println("movie available are \n 1.shreak \n 2.stuart little ");
            Scanner a = new Scanner(System.in);
            int o = a.nextInt();
            if (o == 1) {
                System.out.println("shreak movie @ kaurnya theater");
                System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=40*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- karunya theater");
                    System.out.println("movie --------------------- shreak");
                    System.out.println("cost ---------------------- Rs."+amount);
                    System.out.println("******************************************************");
                }

            }
            if (o == 2) {
                System.out.println("stuart little @karunya theater");
                 System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=50*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- karunya theater");
                    System.out.println("movie --------------------- staurt little");
                    System.out.println("cost ---------------------- Rs"+amount);
                    System.out.println("******************************************************");
                }

            }

        }
        if (n == 2) {
            System.out.println("*******anna theater*******");
            System.out.println("*******select a movie*******");
            System.out.println("movie available are \n 3.game movie \n 4.fun movie");
            Scanner b = new Scanner(System.in);
            int p = b.nextInt();
            Scanner a = new Scanner(System.in);
            int o = a.nextInt();
            if (o == 1) {
                System.out.println("game movie @ anna theater");
                 System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=60*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- anna theater");
                    System.out.println("movie --------------------- game movie");
                    System.out.println("cost ---------------------- Rs."+amount);
                    System.out.println("******************************************************");
                }

            }
            if (o == 2) {
                System.out.println("fun little @anna theater");
                 System.out.println("enter the number of tickets to be booked");
                Scanner j = new Scanner(System.in);
                int r = j.nextInt();
                int left= no_f_tickets-r;
                int amount=70*r;
                System.out.println("to continue to book for this movie prees 1");
                Scanner d = new Scanner(System.in);
                int h = d.nextInt();
                System.out.println("\n\n\n");
                if (h == 1) {
                    System.out.println("******************************************************");
                    System.out.println("theater ------------------- anna theater");
                    System.out.println("movie --------------------- fun movie");
                    System.out.println("cost ---------------------- Rs."+amount);
                    System.out.println("******************************************************");
                }

            }
        }

    }
}

public class labfr {

    public static void main(String[] args) {
        BookMyshow ob = new BookMyshow();

        BookMyshow[] moviename = new BookMyshow[2];
        moviename[0] = ob;
        thea a = new thea();
        moviename[1] = a;

        System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
        System.out.println("---------1.list of movies and their prices--------- \n-------2.acces and book tickets through theaters---");

        System.out.println("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        Scanner d = new Scanner(System.in);
        int h = d.nextInt();
        switch (h) {
            case 1: {
                ob.movies();
                break;
            }
            case 2: {
             
                a.th();
            }
        }

    }

}


output:

Friday, February 10, 2017

java program to print perfect numbers between two limits the {min,max}={1,50}.


public class perfect {

public static void main(String[] args) {
int n = 1;
System.out.println("*****program to find d num of perfect num's b/w 2 limits****** \n ");
for (int i = 1; i <= 50; i++) {
int sum = 0;
for (n = 1; n < i; n++) {
if (i % n == 0) {
sum = sum + n;
}
}
if(sum==i)
System.out.println(i);
}
}
}