Tue Sep 04, 2012 2:02 pm
package doc;
public class Doctor
{ private String name;
private int fees;
private String sp;
private double noVisit;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getFees() {
return fees;
}
public void setFees(int fees) {
this.fees = fees;
}
public String getSp() {
return sp;
}
public void setSp(String sp) {
this.sp = sp;
}
public double getNoVisit() {
return noVisit;
}
public void setNoVisit(double noVisit) {
this.noVisit = noVisit;
}
}
package doc;
public class Hospital
{
Doctor[] doc=new Doctor[3];
private String hosName;
private String add;
private int rooms;
public String getHosName() {
return hosName;
}
public void setHosName(String hosName) {
this.hosName = hosName;
}
public String getAdd() {
return add;
}
public void setAdd(String add) {
this.add = add;
}
public int getRooms() {
return rooms;
}
public void setRooms(int rooms) {
this.rooms = rooms;
}
Hospital(String hosName,String add,int rooms)
{ this.hosName=hosName;
this.add=add;
this.rooms=rooms;
}
void checDoc(String drName)
{
int i;
int count=0;
String name;
for(i=0;i<3;i++)
{
if(doc[i].name[i].equals(drName))
{ System.out.println("doctor found");
}
else
{
System.out.println("doctor not found");
}
}
}
void totCharges()
{
int c;
double sum=0;
for(c=0;c<3;c++)
{ double noVisit;
double charge[c]=(double) (doc[c].noVisit[c])*1000;
sum=sum+charge;
System.out.println("total charges"+sum);
}
}
}
public class Main
{
public static void main(String b[])
{
String[] name={"saru","viji","babu"};
String[]sp={"mbbs","phd","phd"};
int[] noVisit={5,2,3};
int i;
for(i=0;i<3;i++)
{
Doctor doc[i]=new Doctor();
doc[i].setName( name[i]);
doc[i].setSp( sp[i]);
doc[i].setNoVisit( noVisit[i]);
doc[i].checkDoc("saru");
doc[i].totalCharge();
}
}
}
Fri Sep 07, 2012 12:39 am
void checDoc(String spec)
{
int i;
int count=0;
String name;
for(i=0;i<3;i++)
{
if(doc[i].getSp().equals(spec))
{ System.out.println("doctor with specialization : "+spec+" is found");
}
else
{
System.out.println("doctor not found");
}
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.