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
Modules of software: 1 - Serial RS232 comm port comunication 2 - NanoHTTPD serving some processed pages 3 - System tray application to indicate status and access configura

Explain The ?  operator in Java ? The value of a variable frequent depends on whether a particular boolean expression is or is not true and on nothing else. For example one ge

Each time an object is started in Java it goes into the area of memory named as heap. The primitive variables like double and int are allocated in the stack, if they are local inst

Write a Java Applet which will draw a face on applet as follows:   b)    Modify the program now by adding two Buttons (Java version of ActiveX Control) named Smily Fac

Explain what is Object in JAVA language? They are foundation of object oriented language. They are data structure holds data fields and properties and methods

1-4 Problem Set: Arithmetic Consider the following statement when responding to questions 1 and 2: Jim develops 5 Java applications a year. Joe develops 10 Java applications a year

eAgro Portal Project: Technology Used: Java Server Faces, JSR 168 Specification, Websphere Portal Server5.0, DB2 database And Rational Application Developer, Jasper Report Too

This project is based on the teams example of chapter 1. Instead of teams, you will consider employees working in a department in a company. (Departments and employees are analog

Creating applications based on SOA Select your implementation technologies carefully. Carefully check if Web services are suitable. Sometimes using traditional methods suc

The flow control statements give you to conditionally execute statements, to repeatedly operate a block of statements, or to just modify the sequential flow of control.