When the store opened almost two weeks ago, I had to miss two (2) of my classes just to attend to stock operations. And, up to this date, business works continue to consume me that my teaching works indeed pile up.
I have to however squeeze in my works and simply prioritize whatever is more urgent and needed. It is quite wiser and important that we pursue security over our works, properties and family just in case unexpected events happen. Thus, it can be wiser for me and everyone else if insurance like health and cheap car insurance can be one of our top priorities.
Because of the missed classes, I have to cope with my absences and that means putting extra hours in school to attend to my students and their subject requirements.
The extended time will be over soon and I can only be more relieved.
Thursday, July 29, 2010
Another illustration of exception handling is the use of exception type, ArithmeticException which is normally used for division by zero among other arithmetic operations.
See the program below for this example.
[+/-] show/hide
/* program for try and catch */
import java.lang.*;
import java.io.*;
public class TryDemo2{
public static void main ( String args[]) throws IOException{
BufferedReader stdin = new BufferedReader(new InputStreamReader (System.in));
System.out.println("Input a numerator:");
String numerator=stdin.readLine();
int num1=Integer.parseInt(numerator);
System.out.println("Input a divisor:");
String divisor=stdin.readLine();
try{
int num2=Integer.parseInt(divisor);
System.out.println("The quotient of "+numerator+" and "+divisor+" is "+num1/num2);
}
catch (ArithmeticException ex){
System.out.println("Division by zero! ");
}
}
}
See the program below for this example.
[+/-] show/hide
/* program for try and catch */
import java.lang.*;
import java.io.*;
public class TryDemo2{
public static void main ( String args[]) throws IOException{
BufferedReader stdin = new BufferedReader(new InputStreamReader (System.in));
System.out.println("Input a numerator:");
String numerator=stdin.readLine();
int num1=Integer.parseInt(numerator);
System.out.println("Input a divisor:");
String divisor=stdin.readLine();
try{
int num2=Integer.parseInt(divisor);
System.out.println("The quotient of "+numerator+" and "+divisor+" is "+num1/num2);
}
catch (ArithmeticException ex){
System.out.println("Division by zero! ");
}
}
}
Labels:Java,lectures,sample programs,source codes
| Reactions: |
Catch Errors through Exceptions
Exceptions in Java can come in 3 forms: errors, runtime exceptions and logical exceptions. Errors and logical exceptions should be corrected as these affect the program's reliability and accuracy. However, runtime exceptions like division by zero, wrong input format, array access out of size, and etc. However, Java can handle these exception through try -- catch blocks.
Typically, NumberFormatException is encountered when a non-numeric input is encoded for a number input. This shall cause a program disruption that shows up the stack trace or the causes of disruption and from what method among other information.
The sample program below shows the use of exception.
[+/-] show/hide
/*program for try and catch */
import java.lang.*;
import java.io.*;
public class TryDemo1{
public static void main ( String args[]) throws IOException{
BufferedReader stdin = new BufferedReader(new InputStreamReader (System.in));
String myInput;
System.out.println("Input an integer:");
myInput=stdin.readLine();
try{
int num=Integer.parseInt(myInput);
System.out.println("The square of "+num+" is "+num*num);
}
catch (NumberFormatException ex){
System.out.println("You have encoded a wrong input");
}
System.out.println("Goodbye!");
}
}
Typically, NumberFormatException is encountered when a non-numeric input is encoded for a number input. This shall cause a program disruption that shows up the stack trace or the causes of disruption and from what method among other information.
The sample program below shows the use of exception.
[+/-] show/hide
/*program for try and catch */
import java.lang.*;
import java.io.*;
public class TryDemo1{
public static void main ( String args[]) throws IOException{
BufferedReader stdin = new BufferedReader(new InputStreamReader (System.in));
String myInput;
System.out.println("Input an integer:");
myInput=stdin.readLine();
try{
int num=Integer.parseInt(myInput);
System.out.println("The square of "+num+" is "+num*num);
}
catch (NumberFormatException ex){
System.out.println("You have encoded a wrong input");
}
System.out.println("Goodbye!");
}
}
Labels:Java,lectures,sample programs,source codes
| Reactions: |
Thursday, July 22, 2010
How to Enhance Social Skills in School
I was never an extrovert person before where I spent most of my schooling days only indoor and academic. However, from prior experience and teaching exposures, you too can develop your social skills. You can employ the following tips to rid gradually your inhibition from social activities.
1. Develop small group of friends who share with you similar interests and values;
2. Be open to welcoming new acquaintances from your friends' circles;
3. Join academic or non - academic groups;
4. Take personality - enhancement talks or fora;
5. Join in social events - start with required activities and extend these to off - school fun; and
6. Enjoy the company of others.
7. Enhance your personality through fashion and body makeover, regular exercise, diet and other personality - boosting measures like apidexin to complement your weight loss/gain programs.
Being alone may mean fun too, however, social skills are imperative whenever you wish to work. Thus, exposure while in school can gradually help you improve your interpersonal skills and through this, your confidence is further boosted. It will simply come handy when you assert your worth as you apply for or pursue a job.
1. Develop small group of friends who share with you similar interests and values;
2. Be open to welcoming new acquaintances from your friends' circles;
3. Join academic or non - academic groups;
4. Take personality - enhancement talks or fora;
5. Join in social events - start with required activities and extend these to off - school fun; and
6. Enjoy the company of others.
7. Enhance your personality through fashion and body makeover, regular exercise, diet and other personality - boosting measures like apidexin to complement your weight loss/gain programs.
Being alone may mean fun too, however, social skills are imperative whenever you wish to work. Thus, exposure while in school can gradually help you improve your interpersonal skills and through this, your confidence is further boosted. It will simply come handy when you assert your worth as you apply for or pursue a job.
| Reactions: |
Subscribe to:
Posts (Atom)










