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
Implement a program to query and update the text database for a library using a client/server model allowing multiple clients safe access to the database, and using a producer-cons

Point-To-Point (PTP). This model permits exchanging messages via queues formed for some purposes. A client can send and receive messages from one or various queues. PTP model is ea

To change c code and place into a java application Project Description: To change c code and place into a java application Skills required are C Programming, Java, Softwar

How to create a program using sprite sheet?

Prepare an android keyboard Project Description: I want to prepare an android keyboard that have many features.( i will describe later) I want the full app and a trial ver

1. Write the code for the method that calculates the number of unique shapes for a binary search tree with n nodes. Use the formula  where b n is the number of possible sh

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

Difference between Hash Map and Hash Table? The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and allows nulls. (HashMap allows null values

Project Description: A web developer is required to finish a webcam site with basic account management and voting functionality. The website can make use of a third party fla

I have a parser. it is written in Java. I need to add a hash table to it. I am wondering about if you can do it.