Posts

Showing posts from October, 2012

ATM Java code

Image
This is an ATM kind of machine. Programmed without exceptions. ...................................................... import javax.swing.*; /**@author LEE (Mafanga Lolito)  *  * @version ATM PIN Checker 1.0 (Without Exceptions)  *  * @since  : 04 September 2012  */ public class ATM{ public static void main ( String args []){ int countWrong = 3; int pin = 123; int thePin = 0; while ( thePin != pin){ String thePinString= JOptionPane.showInputDialog(null,"Enter your Password :","Umbrella Corporation!"); thePin = Integer.parseInt(thePinString); // Counts wrong pins entered countWrong--; //if the count is = 3, meaning the wrong pin is entered 3 times //the program breaks and displays the message if ( countWrong == 0 && thePin != pin){ JOptionPane.showMessageDialog(null,"ACCESS  REVOKED!\n","Umbrella Corporation.", JOptionPane.ERROR_MESSAGE); JOptionPane

Leap Year Java Program

Image
This program confirms if the entered year is a leap year or not. ................................................................................................................................................................... import javax.swing.JOptionPane; public class LeapYear { public static void main(String args[]){ int Year=0; boolean goodInput = false; //JOptionPane.showMessageDialog(null, // "This program shows whether the year you are about " + //"to enter is a leap year or not . "); String YearString=JOptionPane.showInputDialog(null,"Enter the year :"); do    {      try      {        // attempt to convert the String to an integer        Year = Integer.parseInt( YearString );                goodInput = true;          }      catch (NumberFormatException nfe)      {        YearString = JOptionPane.showInputDialog( null,"'"+YearStrin