This will teach you the way to convert strings to upper case in javascript. we will use these if we've a text field needs to capitalized all inputted text or simply the 1st letter of the word.
Source :
Hope you learn from this
VB.NET, C#, Java, HTML, JQuery, Javascript, PHP, Software Reviews, Computer Tips and Tech News
import java.util.GregorianCalendar;
import java.util.Scanner;
import java.util.InputMismatchException;
public class age_calculator {
public static void main(String[] args) {
int day = 0;
int month = 0;
int year = 0;
Scanner scan = new Scanner(System.in);
try{
System.out.print("Day: ");
day = scan.nextInt();
System.out.print("Month: ");
month = scan.nextInt();
System.out.print("Year: ");
year = scan.nextInt();
}
catch(InputMismatchException e){
System.out.println("Error: You entered an invalid number");
System.exit(1);
}
System.out.println("\nYou are " + getAge(day,month,year) + " years old");
}
public static int getAge(int day, int month, int year){
final int ERROR = -1;
//initialize GregorianCalendar with current date
GregorianCalendar cal = new GregorianCalendar();
//constant holds current day
final int CDAY = cal.get(GregorianCalendar.DAY_OF_MONTH);
//constant hold current month
final int CMONTH = cal.get(GregorianCalendar.MONTH) + 1;
//constant to hold current year
final int CYEAR = cal.get(GregorianCalendar.YEAR);
//check if current day of the month is greater then birth day
if (month == CMONTH){
if(CDAY >= day)
return CYEAR - year;
if(CDAY < day)
return CYEAR - year - 1;
}
//check if birth month is less then current month
else if(month < CMONTH)
return CYEAR - year;
//subtract 1 from the age because the current day in the month is less then birth date
else
return CYEAR - year - 1;
return ERROR;
}
}
/*+---------------------------------Adeel Mahmood---------------------------------+*\
/*+---------------------------------Port Scanner----------------------------------+*\
/*=-------------------------adeelmahmood1982@ukonline.co.uk------------------------+*\
/************************************************************************************/
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
public class PortScanner extends Frame{
Socket s;
int startPort,endPort;
Label l1;
TextField hostName,fromPort,toPort;
TextArea log;
Label host,from,to,label;
Button scan,reset;
int fp,tp;
String h;
static boolean close=false;
Dialog d;
public PortScanner(){
Frame f=new Frame("Port Scanner");
f.setVisible(true);
f.setLayout(new GridLayout(5,1));
l1=new Label("Port Scanner version 1.0",Label.CENTER);
l1.setForeground(Color.blue);
l1.setFont(new Font("TimesRoman",Font.BOLD,20));
f.add(l1);
Panel p1=new Panel(new GridLayout(3,3));
host=new Label("Host Name:");
host.setForeground(Color.blue);
p1.add(host);
hostName=new TextField(15);
p1.add(hostName);
from=new Label("From Port:");
from.setForeground(Color.blue);
p1.add(from);
fromPort=new TextField(15);
p1.add(fromPort);
to=new Label("To Port:");
to.setForeground(Color.blue);
p1.add(to);
toPort=new TextField(15);
p1.add(toPort);
f.add(p1);
Panel p2=new Panel();
scan=new Button("Scan Now");
scan.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent r){
if(hostName.getText().equals("")){log.setText("Please complete all the required fields");
return;
}
else if (fromPort.getText().equals("")){log.setText("Please complete all the required fields");
return;}
else if(toPort.getText().equals("")){log.setText("Please complete all the required fields");
return;}
close=false;
Thread run1=new Thread(){
public void run(){
scan.setEnabled(false);
reset.setLabel("Stop");
log.setText("");
log.repaint();
h=hostName.getText();
fp=Integer.parseInt(fromPort.getText());
tp=Integer.parseInt(toPort.getText());
for(int i=fp;i<=tp;i++){
label.setText("Port "+i+" is being tested");
if(close)
break;
try{
s=new Socket(h,i);
log.append("Port "+i+" is open."+"\n");
log.repaint();
s.close();
}
catch(Exception er){continue;}
}
scan.setEnabled(true);
reset.setLabel("Reset");
label.setText("Press Scan to start.");
}
};
run1.start();
}
});
reset=new Button("Reset");
reset.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent t){
Thread run2=new Thread(){
public void run(){
close=true;
hostName.setText("");
fromPort.setText("");
toPort.setText("");
}
};
run2.start();
}
});
Label empty=new Label();
p2.add(scan);
p2.add(empty);
p2.add(reset);
f.add(p2);
log=new TextArea();
f.add(log);
label=new Label("Press Scan to start.");
label.setForeground(Color.blue);
f.add(label);
f.setSize(320,460);
//f.show(true);
f.repaint();
f.setResizable(false);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(1);
}
});
}
public static void main(String args[]){
new PortScanner();
}
}// end of class
tag.
Now you have constructed your own WP theme. But wait! Your theme is developed, but you may find it to be blank. You'll have to add content to it.
Step 4: Add your content
Now you may have to add content in your theme. How will you display the content in your tailor-made WP theme? For this purpose, you require WordPress’ loop function – The Loop.
Installing the loop function, requires copying the following code into your index.php template.
Step 5: Initiate your Theme
To set-up your theme, visit a FTP client and sign in to your website directory.
Go to wp-content>>themes folder.
Upload your new theme folder to this folder. Open your WordPress admin panel, go to Appearance>>themes tab. Your theme will now be visible just click on Activate.
That's it, you are done!
About Author:
Sarah Parker is a developer comes technical writer at Designs2HTML Ltd. She loves to share relevant and useful tutorials on WordPress markup conversions on Twitter to treat technical professionals with required stuffs.