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
This assignment requires you to design, implement and test a program using Java features from the first half of the subject content. You are required to implement in Java all the c

examples of 2D arrays

There are four different parts by which autowiring can be done. ? byName ? constructor ? autodetect ? byType

Project Description: We are seeking software engineers to create a plug-in for Adobe after Effects (CS4 and above) that allows 3D extrusions for a layer. We are seeking somethin

We have to create a world class that contains a 2d array then create an abstract class called organism that contains move() method the organism should move randomly one step at the

In JavaScript, what is event handling? What are the two categories of events? In java script we could capture events on do a few operation on the basis of which particular even

The Java programming language is object-oriented and includes automatic garbage collection. Garbage collection is the process of reclaiming memory taken up by unreferenced objects.

How to Begin a Variable Name with a Number? If you need to starts a variable name along with a digit, prefix the name you'd like to have (e.g. 8ball) along with an underscore,

Explain the char data type in java? A char is a single character in which a letter, a digit, a punctuation mark, a tab, a space or something same. A char literal is a single on

The game of Life, invented by John Conway, is supposed to model the genetic laws for birth, survival, and death (see Scienti_c American, October 1970, p. 120). We will play it on a