Static variable, JAVA Programming

import java.text.NumberFormat;
import java.util.Locale;

public class Client
{
   // instance data
   private String name;
   private long income_this_year;
   private double percent_cut;
   
   // static data
   public static final int MIN_INCOME_VAL = 0;
   public static final int MAX_INCOME_VAL = 50000;
   public static final int MIN_NAME_LEN = 2;
   public static final int MAX_NAME_LEN = 20;
  
   // default constructor
   Client()
   {
      name = "undefined";
      income_this_year = MIN_INCOME_VAL;
      percent_cut = 0;
   }
  
   // parameter constructor
   Client(String str_name, long annualIncome, double cut)
   {
      if (!SetClient(str_name, annualIncome, cut))
         SetClient();
   }
  
   public void SetClient()
   {
      SetClient("undefined", MIN_INCOME_VAL, 0.0);
   }
  
   // accessor
   String GetName() { return name; }
   long GetIncome() { return income_this_year; }
   double GetCut() { return percent_cut; }
  
   // mutators
   public boolean SetClient(String str_name, long annualIncome, double cut)
   {
      if (str_name.length() > MIN_NAME_LEN || str_name.length() < MAX_NAME_LEN
            && annualIncome > MIN_INCOME_VAL ||
            annualIncome < MAX_INCOME_VAL
            && cut > 0.0 || cut < 100.0)
      {
         name = str_name;
         income_this_year = annualIncome;
         percent_cut = cut;
         return true;
      }
      return false;
   }
  
   NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US);
  
   public String ToShow()
   {
      String display = "\nClient: "
            + "\n Name: \t\t\t" + name
            + "\n Annual Income: \t" + currencyFormat.format(income_this_year)
            + "\n Percent cut: \t\t" + percent_cut + "%";
      return display;
   }
  
   // method Display()
   public void Display()
   {
     
      System.out.println(ToShow());
   } 
}

Posted Date: 2/19/2013 5:54:48 AM | Location : United States







Related Discussions:- Static variable, Assignment Help, Ask Question on Static variable, Get Answer, Expert's Help, Static variable Discussions

Write discussion on Static variable
Your posts are moderated
Related Questions
Question: A new software engineer has joined Axistex Ltd. The systems analyst informs him that the organisation works with different operating system. The HR department works w

what is the default modifiers for methods in interface

Make Changes to an Editable PDF Form Project Description: I need for someone who is able to make some changes to PDF forms. Skills required: Data Processing, Data Entry

A BeanFactory is like a factory class that having a collection of beans. The BeanFactory holds Bean Definitions of multiple beans within itself and then instantiates the bean whene

What are the advantages of multimedia presentations? Write any five. Multimedia presentation is a excellent tool for effective communication: Advantages: 1. Easy to make l

What is Externalizable interface? Externalizable is an interface which have two methods readExternal and writeExternal. These methods give you a control over the serialization

Project Description: A java application is required with the subsequent features 1. Ability to use GSM Modem (and/or Mobile phones) or SMPP to send and receive SMS messages

We need an OpenGL - based visualisation of an OBJ-File that was created out of Maya3D. (important: we have to use OpenGL with Java - JOGL) In other words: we have an OBJ-file (a

Struts framework                            J a v a Server Faces More matured since Struts has been started for a few years. It has got var

API consumer -This application should consume a third party API -You should use more than just one method of the API, I'd like to see at least 3 or 4 -Have some concept