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
      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))
   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()

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

Im receiving an error message of Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at Homework.main(

Elaborate with examples Vector or Object oriented graphics? Vector or Object-Oriented Graphics treats everything which is drawn as an object. Objects retain their identity afte

In the lectures, we have written programs for bond pricing in discrete time. We have also talked about the theory for bond pricing and yields in continuous time. In this exercise,

Write nonrecursive implementations of the min() and floor() methods in Make sure to use only one return in your method. Use an insertion sort (discussed in class) to s

What is Resuscitation Trolley explain their features? A proper resuscitation kit is mandatory for the ICU. In addition to trolleys that can be moved around the ICU there should

Get info from website using javascript Project Description: I need to extract the text from all the available (red, blue) seats of all the events on this site without getting

15. Energy Drink Consumption A soft drink company recently surveyed 12,467 of its customers and found that approximately 14 percent of those surveyed purchase one or more energy dr

Java platform is a software-only platform independent, which runs on top of other hardware-based platforms like WINDOWS, UNIX, NT etc.   The Java platform has 2 main com

What Can an Applet Do? An applet can: • Draw pictures on a web page • Create a new window and draw in it. • Play sounds. • Receive input from the user by the keyboard or