Sunday, 10 July 2016

Core Java Assignment

Question No.1


Answer -1

import java.util.*;

class Roomctagory

{

int RoomCatagoryId;

varchar Name;

varchar Description;

float Tarrif;

}



class Booking

{

int BookingId;

varchar CustomerName;

varchar CustomerAddress;

varchar CustomerPhone;

Int RoomId;

Timestamp BookingDateTime;

Timestamp CheckinDate;

Timestamp CheckoutDate;

}

class Room

{

int RoomId;

int RoomCatagoryId;

char Status;

}




class MyClass

{

public static void main(String[] args)

{

System.out.println("RoomCatagory, Booking and Room are the three classes.");

}

}


Question No.2



Answer-2

import java.sql.*;

import java.util.*;

class JoinTable

{

public static void main(String[] args) throws SQLException

{

try

{

Class.forName("sun.jdbc.odbc.jdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:Sql","sa","password@123");

Statement stmt=con.createStatement();

ResultSet rs=stmt.executeQuery("select Booking_id , Customer_Name, RoomCatagory_id,Room_id, Checkin_Date, Checkout_Date, Tariff");

while (rs.next())

{

System.outlprintln("\n"+rs.getInt(1)+"\t"+rs.getInt(2)+"\t"+rs.getString(3)+"\t"+rs.getString(4)+

"\t"+rs.getString(5)+"\t"+rs.getString(6)+"\t"+rs.getString(7)+"\t"+rs.getInt(8)+);

}

con.close();

stmt.close();

}

catch(Exception e)

{

}

System.out.println("Records retreived successfully....");

}

}


Question No.3
Answer-3

import java.sql.*;

import java.util.*;

class RoomCatagory

{

public static void main(String args[]) throws SQLException

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:SQL","sa","password@123");

PreparedStatement stmt=con.prepareStatement("insert into RoomCatagory values(?,?,?,?)");

Scanner sc=new Scanner(System.in);

System.out.println("Enter RoomCatagory ID");

int pid=sc.nextInt();

System.out.println("Enter Name ");

String pn=sc.next():

System.out.println("Enter Description");

int did=sc.nextInt();

System.out.println("Enter Tarrif");

String pad=sc.next():



stmt.setInt(C001, Katrina kaif, Delux, 10% );

stmt.setInt(C002, Amir Khan, Super Delux, 5%);

stmt.setInt(C003, Sharukh Khan, Economic, 2%);

stmt.setInt(C004, Deepika Padukone, Premium, 25%);

stmt.executeUpdate();

con.close();

stmt.close();


}

Catch(Exception e)

{

}

System.out.println("Records Inserted Successfully !!!");

}




class Booking

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:SQL","sa","password@123");

PreparedStatement stmt=con.prepareStatement("insert into Booking values(?,?,?,?,?,?,?,?)");

Scanner sc=new Scanner(System.in);

System.out.println("Enter Booking ID");

int pid=sc.nextInt();

System.out.println("Enter Customer Name");

String pn=sc.next();

System.out.println("Enter Customer Address");

int did=sc.nextInt();

System.out.println("Enter Customer Phone");

String pad=sc.next();

System.out.println("Enter Room ID");

String pg=sc.next();

System.out.println("Enter Booking DateTime");

String pg=sc.next();

System.out.println("Enter Checkin Date");

String pg=sc.next();

System.out.println("Enter Checkout Date");

String pg=sc.next():


stmt.setInt(B001, Sandeep, Malviya nagar, 8800225588, R001, 3th March 2015 10:30AM, 8 March 2015, 15 March 2015 );

stmt.setInt(B002, Mohit, Punjabi Bhag, 8800115588, R002, 4th March 2015 10:00AM, 9 March 2015, 16 March 2015 );

stmt.setInt(B003, Perpendicular, Harsh Vihar, 8800225577, R003, 5th March 2015 09:30AM, 10 March 2015, 17 March 2015 );

stmt.setInt((B004, Tangent, Patel Chowk, 8800227788, R004, 7th March 2015 11:00AM, 12 March 2015, 18 March 2015 );


stmt.setSting();

con.close();

stmt.close();


}

Catch(Exception e)

{

}

System.out.println("Records Inserted Successfully !!!");

}

}





class Room

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:SQL","sa","password@123");

PreparedStatement stmt=con.prepareStatement("insert into Room values(?,?)");

Scanner sc=new Scanner(System.in);

System.out.println("Enter Room ID");

int pid=sc.nextInt();

System.out.println("Enter RoomCatagory ID");

String pn=sc.next();

System.out.println("Enter Status ID");

String pn=sc.next();


stmt.setInt(R001, C001, Available);

stmt.setInt(R002, C002, Not Available);

stmt.setInt(R003, C003, Available);

stmt.setInt(R004, C004, Available);

stmt.setSting();

con.close();

stmt.close();

}

Catch(Exception e)

{

}

System.out.println("Records Inserted Successfully !!!");

}

}

}






2 comments:

  1. C LANGUAGE, C LANGUAGE TUTORIAL, C LANGUAGE EXAMS, C LANGUAGE STUDY, C LANGUAGE ASSIGNMENTS, C LANGUAGE PROJECTS, C LANGUAGE PAPER, C LANGUAGE PREPARATION, OVERVIEW OF C LANGUAGE, FEATURES OF C LANGUAGE, STRUCTURE IN C LANGUAGE, POINTERS IN C LANGUAGE LATEST TIPS AND TRICKS GO TO ===>> https://foundclangguage.blogspot.in/

    ReplyDelete

Note: only a member of this blog may post a comment.