SlideShare uma empresa Scribd logo
1 de 19
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
ADVANCE JAVA LAB
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
Experiment No: 01
AIM:A. Program for printing hello word:
B.Program for printing system Date & Time JSP/SERLET:
A.class Hello{
public static void main (String args[])
{
System.out.println("Java Hello World");
}
}
B. <%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<html>
<head>
<title>Display Current Date & Time</title>
</head>
<body>
<center>
<h1>Display Current Date & Time</h1>
</center>
<%
Date date = new Date();
out.print( "<h2 align="center">" +date.toString()+"</h2>");
%>
</body>
</html>
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
Experiment No: 02
AIM: Write a server side program for finding factorial of number.
import java.io.*;
class Factorial
{
publicstaticvoid main(String args[])
{
String str;
int no,fact;
fact=1;
try{
BufferedReader obj = new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Enter number whose Factorial is to be found : ");
System.out.flush();
str=obj.readLine();
no=Integer.parseInt(str);
while(no > 0)
{
fact=fact*no;
no=no-1;
}
System.out.println("FACTORIAL of a given number is : "+fact);
}
catch(Exception e)
{}
}
Experiment No: 03
AIM: . Write a Server side program in JSP/SERVLET for performing Addition of two no
accept numbers from client side by using HTML form
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
import java.util.Scanner;
class AddNumbers
{
public static void main(String args[])
{
int x, y, z;
System.out.println("Enter two integers to calculate their sum ");
Scanner in = new Scanner(System.in);
x = in.nextInt();
y = in.nextInt();
z = x + y;
System.out.println("Sum of entered integers = "+z);
}
}
Experiment No: 04
AIM: Write a Server side program in JSP/SERVLET for calculating the simple interest accept
the necessary parameters from client side by using.
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
<%--
Document : interest
Created on : 30 Oct, 2012, 10:30:44 PM
Author : NESTED CODE
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
Now we have to create the page "intjsp.jsp" to calculate interest
Code for this "intjsp.jsp" page ::
Document : intjsp
Created on : 30 Oct, 2012, 10:41:10 PM
Author : NESTED CODE
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body><br><br><center><pre><H1>
<%
String ns= request.getParameter("principle");
String ns1= request.getParameter("year");
String ns2= request.getParameter("interest");
int n1=Integer.parseInt(ns);
int n2=Integer.parseInt(ns1);
int n3=Integer.parseInt(ns2);
double si=((n1*n2*n3)/100);
double x;
x=n1+si;
%>
<%
out.println("Principal= "+n1);
out.println(" Years= "+n2);
out.println(" Rate of Interest= "+n3);
out.println("<br> ");
out.println(" Simple Interest= "+si);
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
out.println(" Simple Interest= "+x);
%>
</H1>
</pre>
</center>
</body> </body>
</html>
Experiment No: 05
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
AIM: Write a Server side program in JSP/SERVLET for solving Quadratic Equation
accept necessary parameters from HTML form
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Quad Solver</title>
</head>
<body>
<FORM action="GreetingServlet" method="POST">
Quadratic Equation Solver for Equations in the form of
Ax^2 + Bx + C<BR>
<BR>
Enter the value of A: <INPUT type="text" name="A" size="15"><BR>
Enter the value of B: <INPUT type="text" name="B" size="15"><BR>
Enter the value of C: <INPUT type="text" name="C" size="15"><BR>
<br>
<input type="submit" value="Calculate!">
<br>
<BR>
<BR>
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
</FORM>
</body>
</html>
GreetingServlet.java
package com.mycompany.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class GreetingServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public GreetingServlet() {
super();
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String A = request.getParameter("A").toString();
String B = request.getParameter("B").toString();
String C = request.getParameter("C").toString();
double a = Double.parseDouble(A);
double b = Double.parseDouble(B);
double c = Double.parseDouble(C);
double D = QuadraticSolver.getD();
double[] roots = QuadraticSolver.quadratic();
out.println("<html>");
out.println("<head>");
out.println("<title>Quadratic Equation Solver</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Quadratic Equation Solver </h1>");
out.println("<h2>Your Equation is: <br><br>" + A + "x^2 + " + B + "x + " + C+
"<br>");
//QuadraticSolver solver = new QuadraticSolver ();
out.println("</h2>");
//double D = QuadraticSolver.getD();
if (a == 0.0)
out.println("<br>This is not a Quadratic quation ! ");
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
if (b == 0.0)
out.println("<br>There is no solution ! ");
if (a > 0.0 && b > 0) {
out.println("<br><br>There is only 1 solution -C/B : " );
out.println("<br><br>Your Solution is : - "+ c + " / " + b + " equals" + -c/b );
out.println("<br><br> X1 = "+ roots[0] );
out.println("<br><br> X2 = "+ roots[1] );
if(roots !=null){
out.println("<br><br>Solutions are:<br><br> X1 = " + roots[0] + " or X2 = " +
roots[1]+"<br>");
}
Else
{
out.println("<br><br>There Are No Real Solutions !!");
}
out.println("</h2>");
out.println("</body>");
out.println("</html>");
out.close();
}
}
}
QuadraticSolver.java
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
package com.mycompany.servlet;
import static java.lang.StrictMath.*;
public class QuadraticSolver {
static double a;
static double b;
static double c;
//double D;
double discriminant = 0.0;
double root1;
double root2;
static double[] quadratic() {
double a = 0;
double b = 0;
double c = 0;
// Return the roots of the quadratic equation
double[] roots = new double[2];
double D = Math.pow(b, 2) - (c*1)*(-c);
if (D<0) {
System.out.println("There are no real roots");
System.out.println(D);
return roots;
}
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
// Use Viete's formula to avoid loss of significance
//double q = -0.5 * (b + copySign(sqrt(d), b));
/roots[0] = q/a;
//roots[1] = c/q;
//return roots;
//roots[0]=-b/2/a+Math.pow(Math.pow(b,2)-4*a*c,0.5)/2/a;
roots[0] = ((-b + sqrt(D)) / (2 * a));
return roots;
}
static double getD() {
double D=0;
D = b * b - 4.0f * a * c;
return D;
}
public static void main(String[] args) {
//double D=0;
// D = Math.pow(b, 2) - (c*a)*(-c);
double D = QuadraticSolver.getD();
double[] roots = quadratic();
System.out.println(roots[0]);
System.out.println(roots[1]);
}
My Directory structure:
MyFirstServlet
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
Deployment descriptor:MyFirstServlet
Java Resources :src
Com.mycompany.servlet
GreetingServlet.java
QuadraticSolver.Java
Libraries
Java Script resources
Build
WebContent
META-INF
WEB-INF
Classes
Lib
Web.xml
Index.jsp
Experiment No: 06
AIM: Write a Server side program in JSP/SERVLET for Income Tax Calculation
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Calculate Interest JSP</title>
</head>
<body>
<%
String fname = request.getParameter("fname");
String lname = request.getParameter("lname");
String gender = request.getParameter("gender");
String profession = request.getParameter("profession");
String prefix = " ";
if (gender.equals("Male")) { prefix = "Mr."; }
else if (gender.equals("Female")) { prefix = "Ms."; } %>
<FONT COLOR = "Blue">Hello <%=prefix
%>&nbsp;<%=fname%>&nbsp;<%=lname%> &nbsp; who works in a
<%=profession %></FONT>
<% String sincome = request.getParameter("income");
float income = Float.parseFloat(sincome);
out.println("<BR>Your Annual Income is <FONT COLOR = Blue> " +income +
"</FONT>");
float tax;
float diff;
if(income <= 100000)
{
out.println("<BR>You are below the Tax Bracket!!");
}
else if(income >100000 && income <= 200000)
{
out.println("<BR>Your Tax Bracket is between Rs.1,00000 to Rs.2,00000");
out.println("<BR><B><U> Tax Rule: </U></B>10% of income above Rs.1
Lakh");
diff = income - 100000;
tax = (float)0.1*diff;
out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax+
"</FONT>");
}
else if(income >200000 && income <= 300000)
{
out.println("<BR>Your Tax Bracket is between between Rs.1,00000 to
Rs.3,00000");
out.println("<BR><B><U>Tax Rule: </U></B> 10% of income upto Rs.1 Lakh
and 20% of rest of income");
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
diff = income - 200000;
tax = (float)0.2*diff + (float)0.1*100000;
out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax+
"</FONT>");
}
else if(income >100000 && income <= 400000)
{
out.println("<BR>Your Tax Bracket is between Rs.1,00000 to Rs.4,00000");
out.println("<BR><B><U>Tax Rule: </U></B>10% of income upto Rs.1 Lakh
20% of income upto Rs.3 Lakh and 30% of rest of income");
diff = income - 300000;
tax = (float)0.3*diff + (float)0.2*200000 + (float)0.1*100000;
out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax);
}
else if(income > 400000)
{
out.println("<BR>You fall in the tax bracket greater than Rs.4,00000");
diff = income - 400000;
tax = diff + (float)0.3*300000 + (float)0.2*200000 + (float)0.1*100000;
out.println("<BR><B><U>Tax Rule:</U></B> 10% of income upto Rs.1 Lakh
20% of income upto 3Lakh, 30% of income upto Rs.4 lakh and 100% of rest of
income");
out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax+
"</FONT>");
}//end if %>
</body>
</html>
Experiment No: 07
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
AIM: Program:Write a server side JSP/SERVLET program for checking prime number,
accept number from html file handover the no to JSP/Servlet file process it and return the
result.
<%--
Document : index
Created on : 12 Oct, 2012, 7:35:11 PM
Author : nested code team
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body><br><br><center>
<form action="primejsp.jsp ">
<h1>Enter the no :: <input type=text name=n ><br><br>
<input type=submit value="Submit"></h1>
</form></center>
</body>
</html>
Now we have to create the page "primejsp.jsp" to calculate interest
Code for this "intjsp.jsp" page ::
<%--
Document : primejsp
Created on : 31 Oct, 2012, 11:59:34 AM
Author :NESTED CODE
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body><center><h1>The required Result is:: </h1>
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
<h2>
<% int n,i,flag=0;
String ns= request.getParameter("n");
n=Integer.parseInt(ns);
if(n>1)
{
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
}
if(flag==0)
{
out.println("<pre>");
out.println(n+" is a prime no.");
out.println("</pre>");
}
else
{
out.println("<pre>");
out.println(n+" is not a prime no.");
out.println("</pre>");
}
%>
</h2></center>
</body>
</html>
The Outpur will be like ::
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha
Experiment No: 08
AIM: WAP for swapping of two numbers.
package swap;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int a,b;
System.out.println("Enter the two numbers: ");
Scanner s= new Scanner(System.in);
a = s.nextInt();
b = s.nextInt();
System.out.println("Number before swapping:" +a+" " +b);
a=a+b;
b=a-b;
a=a-b;
System.out.println("Number after swapping:" +a+" " +b);
}
}
SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.)
CSE/8th
/Advance JavaLab/PreparedbyVivekKumarSinha

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
662305 10
662305 10662305 10
662305 10
 
Lecture on graphics
Lecture on graphicsLecture on graphics
Lecture on graphics
 
Struct examples
Struct examplesStruct examples
Struct examples
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
C graphics programs file
C graphics programs fileC graphics programs file
C graphics programs file
 
Arrays
ArraysArrays
Arrays
 

Destaque (19)

Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
מצגת סטודנטים מבוא ליחבל בר אילן
מצגת סטודנטים מבוא ליחבל בר אילןמצגת סטודנטים מבוא ליחבל בר אילן
מצגת סטודנטים מבוא ליחבל בר אילן
 
Sophie Scholl
Sophie SchollSophie Scholl
Sophie Scholl
 
= よちよちrbLT大会レポートるびま投稿振り返り
= よちよちrbLT大会レポートるびま投稿振り返り= よちよちrbLT大会レポートるびま投稿振り返り
= よちよちrbLT大会レポートるびま投稿振り返り
 
Sistim semi hydroponic dalam pembibitan tebu
Sistim semi hydroponic dalam pembibitan tebuSistim semi hydroponic dalam pembibitan tebu
Sistim semi hydroponic dalam pembibitan tebu
 
Luta pelos teus ideais
Luta pelos teus ideaisLuta pelos teus ideais
Luta pelos teus ideais
 
Universidade de conhecimento
Universidade de conhecimentoUniversidade de conhecimento
Universidade de conhecimento
 
Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]
 
Unix lab
Unix labUnix lab
Unix lab
 
Dbms lab Manual
Dbms lab ManualDbms lab Manual
Dbms lab Manual
 
Sophie Scholl
Sophie SchollSophie Scholl
Sophie Scholl
 
Cse 7 softcomputing lab
Cse 7 softcomputing labCse 7 softcomputing lab
Cse 7 softcomputing lab
 
Presentasi
PresentasiPresentasi
Presentasi
 
Net neutrality
Net neutralityNet neutrality
Net neutrality
 
Crimes Of Pakistan Army Pt-3
Crimes Of Pakistan Army Pt-3Crimes Of Pakistan Army Pt-3
Crimes Of Pakistan Army Pt-3
 
Introduction to JavaScript Programming
Introduction to JavaScript ProgrammingIntroduction to JavaScript Programming
Introduction to JavaScript Programming
 
DBMS Practical File
DBMS Practical FileDBMS Practical File
DBMS Practical File
 
BUKU PELAJARAN TENTANG SISTEM PENCERNAAN MAKANAN
BUKU PELAJARAN TENTANG SISTEM PENCERNAAN MAKANANBUKU PELAJARAN TENTANG SISTEM PENCERNAAN MAKANAN
BUKU PELAJARAN TENTANG SISTEM PENCERNAAN MAKANAN
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 

Semelhante a Advance java

Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3mihirio
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web developmentJohannes Brodwall
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Hitesh Patel
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.jsVisual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.jsFlorian Georg
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scalarostislav
 
Get Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2DaysGet Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2DaysLukas Eder
 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component PresentationJohn Coonen
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8PrinceGuru MS
 
Data visualization in python/Django
Data visualization in python/DjangoData visualization in python/Django
Data visualization in python/Djangokenluck2001
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know Norberto Leite
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)MongoDB
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 

Semelhante a Advance java (20)

Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
Presentation
PresentationPresentation
Presentation
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.jsVisual Exploration of Large Data sets with D3, crossfilter and dc.js
Visual Exploration of Large Data sets with D3, crossfilter and dc.js
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scala
 
Get Back in Control of your SQL
Get Back in Control of your SQLGet Back in Control of your SQL
Get Back in Control of your SQL
 
Get Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2DaysGet Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2Days
 
Web based development
Web based developmentWeb based development
Web based development
 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component Presentation
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
 
Data visualization in python/Django
Data visualization in python/DjangoData visualization in python/Django
Data visualization in python/Django
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 

Mais de Vivek Kumar Sinha (20)

Software engg unit 4
Software engg unit 4 Software engg unit 4
Software engg unit 4
 
Software engg unit 3
Software engg unit 3 Software engg unit 3
Software engg unit 3
 
Software engg unit 2
Software engg unit 2 Software engg unit 2
Software engg unit 2
 
Software engg unit 1
Software engg unit 1 Software engg unit 1
Software engg unit 1
 
Data structure
Data structureData structure
Data structure
 
Mathematics basics
Mathematics basicsMathematics basics
Mathematics basics
 
E commerce 5_units_notes
E commerce 5_units_notesE commerce 5_units_notes
E commerce 5_units_notes
 
B.ped
B.pedB.ped
B.ped
 
Subject distribution
Subject distributionSubject distribution
Subject distribution
 
Revision report final
Revision report finalRevision report final
Revision report final
 
Lession plan mis
Lession plan misLession plan mis
Lession plan mis
 
Lession plan dmw
Lession plan dmwLession plan dmw
Lession plan dmw
 
Faculty planning
Faculty planningFaculty planning
Faculty planning
 
Final presentation on computer network
Final presentation on computer networkFinal presentation on computer network
Final presentation on computer network
 
Np syllabus summary
Np syllabus summaryNp syllabus summary
Np syllabus summary
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
Induction program 2017
Induction program 2017Induction program 2017
Induction program 2017
 
Vivek
VivekVivek
Vivek
 
E magzine et&amp;t
E magzine et&amp;tE magzine et&amp;t
E magzine et&amp;t
 
Mechanical engineering department (1)
Mechanical engineering department (1)Mechanical engineering department (1)
Mechanical engineering department (1)
 

Último

Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 

Último (20)

(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 

Advance java

  • 1. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha ADVANCE JAVA LAB
  • 2. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha Experiment No: 01 AIM:A. Program for printing hello word: B.Program for printing system Date & Time JSP/SERLET: A.class Hello{ public static void main (String args[]) { System.out.println("Java Hello World"); } } B. <%@ page import="java.io.*,java.util.*, javax.servlet.*" %> <html> <head> <title>Display Current Date & Time</title> </head> <body> <center> <h1>Display Current Date & Time</h1> </center> <% Date date = new Date(); out.print( "<h2 align="center">" +date.toString()+"</h2>"); %> </body> </html>
  • 3. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha Experiment No: 02 AIM: Write a server side program for finding factorial of number. import java.io.*; class Factorial { publicstaticvoid main(String args[]) { String str; int no,fact; fact=1; try{ BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter number whose Factorial is to be found : "); System.out.flush(); str=obj.readLine(); no=Integer.parseInt(str); while(no > 0) { fact=fact*no; no=no-1; } System.out.println("FACTORIAL of a given number is : "+fact); } catch(Exception e) {} } Experiment No: 03 AIM: . Write a Server side program in JSP/SERVLET for performing Addition of two no accept numbers from client side by using HTML form
  • 4. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha import java.util.Scanner; class AddNumbers { public static void main(String args[]) { int x, y, z; System.out.println("Enter two integers to calculate their sum "); Scanner in = new Scanner(System.in); x = in.nextInt(); y = in.nextInt(); z = x + y; System.out.println("Sum of entered integers = "+z); } } Experiment No: 04 AIM: Write a Server side program in JSP/SERVLET for calculating the simple interest accept the necessary parameters from client side by using.
  • 5. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha <%-- Document : interest Created on : 30 Oct, 2012, 10:30:44 PM Author : NESTED CODE --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> Now we have to create the page "intjsp.jsp" to calculate interest Code for this "intjsp.jsp" page :: Document : intjsp Created on : 30 Oct, 2012, 10:41:10 PM Author : NESTED CODE --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body><br><br><center><pre><H1> <% String ns= request.getParameter("principle"); String ns1= request.getParameter("year"); String ns2= request.getParameter("interest"); int n1=Integer.parseInt(ns); int n2=Integer.parseInt(ns1); int n3=Integer.parseInt(ns2); double si=((n1*n2*n3)/100); double x; x=n1+si; %> <% out.println("Principal= "+n1); out.println(" Years= "+n2); out.println(" Rate of Interest= "+n3); out.println("<br> "); out.println(" Simple Interest= "+si);
  • 6. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha out.println(" Simple Interest= "+x); %> </H1> </pre> </center> </body> </body> </html> Experiment No: 05
  • 7. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha AIM: Write a Server side program in JSP/SERVLET for solving Quadratic Equation accept necessary parameters from HTML form index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Quad Solver</title> </head> <body> <FORM action="GreetingServlet" method="POST"> Quadratic Equation Solver for Equations in the form of Ax^2 + Bx + C<BR> <BR> Enter the value of A: <INPUT type="text" name="A" size="15"><BR> Enter the value of B: <INPUT type="text" name="B" size="15"><BR> Enter the value of C: <INPUT type="text" name="C" size="15"><BR> <br> <input type="submit" value="Calculate!"> <br> <BR> <BR>
  • 8. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha </FORM> </body> </html> GreetingServlet.java package com.mycompany.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class GreetingServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public GreetingServlet() { super(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  • 9. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String A = request.getParameter("A").toString(); String B = request.getParameter("B").toString(); String C = request.getParameter("C").toString(); double a = Double.parseDouble(A); double b = Double.parseDouble(B); double c = Double.parseDouble(C); double D = QuadraticSolver.getD(); double[] roots = QuadraticSolver.quadratic(); out.println("<html>"); out.println("<head>"); out.println("<title>Quadratic Equation Solver</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Quadratic Equation Solver </h1>"); out.println("<h2>Your Equation is: <br><br>" + A + "x^2 + " + B + "x + " + C+ "<br>"); //QuadraticSolver solver = new QuadraticSolver (); out.println("</h2>"); //double D = QuadraticSolver.getD(); if (a == 0.0) out.println("<br>This is not a Quadratic quation ! ");
  • 10. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha if (b == 0.0) out.println("<br>There is no solution ! "); if (a > 0.0 && b > 0) { out.println("<br><br>There is only 1 solution -C/B : " ); out.println("<br><br>Your Solution is : - "+ c + " / " + b + " equals" + -c/b ); out.println("<br><br> X1 = "+ roots[0] ); out.println("<br><br> X2 = "+ roots[1] ); if(roots !=null){ out.println("<br><br>Solutions are:<br><br> X1 = " + roots[0] + " or X2 = " + roots[1]+"<br>"); } Else { out.println("<br><br>There Are No Real Solutions !!"); } out.println("</h2>"); out.println("</body>"); out.println("</html>"); out.close(); } } } QuadraticSolver.java
  • 11. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha package com.mycompany.servlet; import static java.lang.StrictMath.*; public class QuadraticSolver { static double a; static double b; static double c; //double D; double discriminant = 0.0; double root1; double root2; static double[] quadratic() { double a = 0; double b = 0; double c = 0; // Return the roots of the quadratic equation double[] roots = new double[2]; double D = Math.pow(b, 2) - (c*1)*(-c); if (D<0) { System.out.println("There are no real roots"); System.out.println(D); return roots; }
  • 12. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha // Use Viete's formula to avoid loss of significance //double q = -0.5 * (b + copySign(sqrt(d), b)); /roots[0] = q/a; //roots[1] = c/q; //return roots; //roots[0]=-b/2/a+Math.pow(Math.pow(b,2)-4*a*c,0.5)/2/a; roots[0] = ((-b + sqrt(D)) / (2 * a)); return roots; } static double getD() { double D=0; D = b * b - 4.0f * a * c; return D; } public static void main(String[] args) { //double D=0; // D = Math.pow(b, 2) - (c*a)*(-c); double D = QuadraticSolver.getD(); double[] roots = quadratic(); System.out.println(roots[0]); System.out.println(roots[1]); } My Directory structure: MyFirstServlet
  • 13. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha Deployment descriptor:MyFirstServlet Java Resources :src Com.mycompany.servlet GreetingServlet.java QuadraticSolver.Java Libraries Java Script resources Build WebContent META-INF WEB-INF Classes Lib Web.xml Index.jsp Experiment No: 06 AIM: Write a Server side program in JSP/SERVLET for Income Tax Calculation <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  • 14. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Calculate Interest JSP</title> </head> <body> <% String fname = request.getParameter("fname"); String lname = request.getParameter("lname"); String gender = request.getParameter("gender"); String profession = request.getParameter("profession"); String prefix = " "; if (gender.equals("Male")) { prefix = "Mr."; } else if (gender.equals("Female")) { prefix = "Ms."; } %> <FONT COLOR = "Blue">Hello <%=prefix %>&nbsp;<%=fname%>&nbsp;<%=lname%> &nbsp; who works in a <%=profession %></FONT> <% String sincome = request.getParameter("income"); float income = Float.parseFloat(sincome); out.println("<BR>Your Annual Income is <FONT COLOR = Blue> " +income + "</FONT>"); float tax; float diff; if(income <= 100000) { out.println("<BR>You are below the Tax Bracket!!"); } else if(income >100000 && income <= 200000) { out.println("<BR>Your Tax Bracket is between Rs.1,00000 to Rs.2,00000"); out.println("<BR><B><U> Tax Rule: </U></B>10% of income above Rs.1 Lakh"); diff = income - 100000; tax = (float)0.1*diff; out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax+ "</FONT>"); } else if(income >200000 && income <= 300000) { out.println("<BR>Your Tax Bracket is between between Rs.1,00000 to Rs.3,00000"); out.println("<BR><B><U>Tax Rule: </U></B> 10% of income upto Rs.1 Lakh and 20% of rest of income");
  • 15. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha diff = income - 200000; tax = (float)0.2*diff + (float)0.1*100000; out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax+ "</FONT>"); } else if(income >100000 && income <= 400000) { out.println("<BR>Your Tax Bracket is between Rs.1,00000 to Rs.4,00000"); out.println("<BR><B><U>Tax Rule: </U></B>10% of income upto Rs.1 Lakh 20% of income upto Rs.3 Lakh and 30% of rest of income"); diff = income - 300000; tax = (float)0.3*diff + (float)0.2*200000 + (float)0.1*100000; out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax); } else if(income > 400000) { out.println("<BR>You fall in the tax bracket greater than Rs.4,00000"); diff = income - 400000; tax = diff + (float)0.3*300000 + (float)0.2*200000 + (float)0.1*100000; out.println("<BR><B><U>Tax Rule:</U></B> 10% of income upto Rs.1 Lakh 20% of income upto 3Lakh, 30% of income upto Rs.4 lakh and 100% of rest of income"); out.println("<BR>Tax to be paid is <FONT COLOR = Blue> "+tax+ "</FONT>"); }//end if %> </body> </html> Experiment No: 07
  • 16. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha AIM: Program:Write a server side JSP/SERVLET program for checking prime number, accept number from html file handover the no to JSP/Servlet file process it and return the result. <%-- Document : index Created on : 12 Oct, 2012, 7:35:11 PM Author : nested code team --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body><br><br><center> <form action="primejsp.jsp "> <h1>Enter the no :: <input type=text name=n ><br><br> <input type=submit value="Submit"></h1> </form></center> </body> </html> Now we have to create the page "primejsp.jsp" to calculate interest Code for this "intjsp.jsp" page :: <%-- Document : primejsp Created on : 31 Oct, 2012, 11:59:34 AM Author :NESTED CODE --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body><center><h1>The required Result is:: </h1>
  • 17. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha <h2> <% int n,i,flag=0; String ns= request.getParameter("n"); n=Integer.parseInt(ns); if(n>1) { for(i=2;i<=n/2;i++) { if(n%i==0) { flag=1; break; } } } if(flag==0) { out.println("<pre>"); out.println(n+" is a prime no."); out.println("</pre>"); } else { out.println("<pre>"); out.println(n+" is not a prime no."); out.println("</pre>"); } %> </h2></center> </body> </html> The Outpur will be like ::
  • 18. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha Experiment No: 08 AIM: WAP for swapping of two numbers. package swap; import java.util.*; public class Main { public static void main(String[] args) { int a,b; System.out.println("Enter the two numbers: "); Scanner s= new Scanner(System.in); a = s.nextInt(); b = s.nextInt(); System.out.println("Number before swapping:" +a+" " +b); a=a+b; b=a-b; a=a-b; System.out.println("Number after swapping:" +a+" " +b); } }
  • 19. SHRI RAWATPURA SARKAR INSTITUTEOF TECHNOLOGY ,NEWRAIPUR (C.G.) CSE/8th /Advance JavaLab/PreparedbyVivekKumarSinha