Skip to main content

Posts

Showing posts from July, 2013

Example using Interface in Java

import java.util.*; interface Num{ int a=5, b=10; } // All identifiers declared within an interface are final public class Add implements Num{   public Add(){  int add=a+b; System.out.println("Sum: "+add); } public static void main(String[] args){ Add ad=new Add(); } } 

Using Scanner class to calculate the total number of words within a string

import java.util.*; public class TotalWords{ Scanner scan=new Scanner(System.in); String text; public void input(){ try{ System.out.printf("Enter A String: "); text=scan.nextLine(); } catch(InputMismatchException e){ System.err.println("Error Occurred!\n"+e.getMessage()); System.exit(0); } } public void compute(){ scan=new Scanner(text); long total=0; while(scan.hasNext()){ scan.next(); total++; } System.out.println("Total Number of Words: "+total); } public static void main(String[] args){ TotalWords TW=new TotalWords(); TW.input(); TW.compute(); } }

Simple Interest Calculation Java Applet

import java.applet.*; import java.awt.*; import java.awt.event.*; import java.io.*; public final class InterestCalcApplet extends Applet implements ActionListener {     TextField principalField, rateField, numYearsField;     double simpleInterest = 0, amount = 0, principal = 0, numYears = 0, rate = 0;     Button calcButton = new Button("Calculate");     boolean error, error2, error3, error4;     int er;     File file;     byte b[];     String cmd = "";     public InterestCalcApplet() {         super();         add("South", calcButton);     }     @Override     public void init() {         try {             principalField = new T...

HTML Code to check the Password strength

<html>     <head>         <title>Password Strength</title>     </head>     <body style="color: white; background-color: #294a8f; text-align: center; text-shadow: 2px; font-family: sans-serif;">     <center>         <div>             <input type="password" id="password" placeholder="Your Password" autofocus/><br>             <button id="strength" onclick="getStrength();" style="appearance: push-button; border-color: #3b5998; background-color: #294a8f; color: white;">Strength</button>             <div id="result"></div>             <script>   ...

Creating Multiple Tabs in HTML

HTML Document is here:- <!DOCTYPE html> <html>     <head>         <title>Tabs</title>         <link rel=alternate href="hello.html" hreflang=en type=text/html title="English HTML">         <link type="text/css" href="tabs.css" rel="stylesheet" />         <meta charset="UTF-8"/>     </head>     <body style="margin: 0;">     <center>         <script src="tabs.js"></script>         <ul id='tabs'>             <li><a href="#one">Tab 1</a></li>             <li><a href="#two">Tab 2</a></li...

Java servlet to check if the entered E-mail exists and the password of the E-mail is correct or not

Here is the Java Source Code:- import java.awt.image.*; import java.io.*; import java.nio.file.*; import java.util.*; import javax.imageio.*; import javax.servlet.ServletException; import javax.servlet.http.*; public class Login extends HttpServlet {     @Override     public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {         String email, password;         email = req.getParameter("email");         password = req.getParameter("password");         if (!(email == null && password == null)) {             login(email, password, req, res);         }     }     private void login(String email, String password, HttpServlet...