/*Write a java program to create and demonstrate packages.*/
package MyPack;
public class Balance
{
String name;
double bal;
public Balance(String n,double b)
{
name=n;
bal=b;
}
public void Show()
{
if(bal<0)
{
System.out.print("--> ");
}
System.out.println(name + ": $" + bal);
}
}
TESTBALANCE.JAVA
import MyPack.*;
class TestBalance
{
public static void main(String args[])
{
Balance test=new Balance("J.J.Jaspers",99.88);
test.Show();
}
}
0 comments:
Post a Comment