Link to home
Start Free TrialLog in
Avatar of eugene007
eugene007

asked on

calculation

This code can be found in HealthClinic.java. The code bellow is suppose to do the following:

If the status attribute for the patient already refers to this health clinic, he/she is charged a standard fee for a consultation, given by the fee attribute.

If the patient is private, there is no change to their balance attribute.

if the patient is not private, the fee multiplied by the gapPerCent attribute is deducted from their balance. For example, if the fee attribute of the HealthClinic is $50, and the gapPerCent is 10.0, then the balance attribute of the patient is reduced by $5.


public void visit(Patient p)
{           
         if(p.getmedicalFacility()==null)
         {
                 register(p);
         }
         else
         {
                if(p.getprivateFund()==true)
                {
          p.setBalance(p.getBalance() + getFee());
      }
      else
      {
                    p.setBalance(p.getBalance() + (getFee() * getgapPerCent()));
                }
                            
      consultation(p);
          }
}


Does my code do that?. If no how do I solve the problem.

You can download the latest code from:

www.mutaiyas.com/db/Medical.zip

Your help is kindly appreciated.

Regards

Eugene
ASKER CERTIFIED SOLUTION
Avatar of Mig-O
Mig-O

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mig-O
Mig-O

but your code does it right. maybe you just have inverse balances...
Avatar of eugene007

ASKER

public void visit(Patient p)
{          
     if(p.getmedicalFacility()==null)
     {
            register(p);
     }
     else
     {
            consultation(p);

            if(p.getprivateFund()==true)
            {
                    p.setBalance(p.getBalance())
            }
            else
            {
                    p.setBalance(p.getBalance() - (getFee() * getgapPerCent()));
            }            
     }
}

public void consulatation(Patient p)
{
          p.setBalance(p.getBalance()-getFee());
          unregister(p);
}


Is this much better.
I figured it out.

How do I change a negative value to a positive value?
a=(a<0?-a:a)
or a=-a, if you want to change positives to negatives, too
p.getBalance()

will return a negative or positive value. If it returns a negative value how do I change it to positive using the method which u have explained.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
boolean negative = (i < 0); so by this can determent if a value is positive or negative.
I also found out about negate() function.
I hope, you succeed with your program. Is it for a course?
Well Im into asp 3.0 actually. Since im interested to use asp.net, therefore im learning java. Then ill move on to c#.

Regards

Eugene