Help coderanch get a
new server
by contributing to the fundraiser

Elaine Banks

Greenhorn
+ Follow
since Dec 16, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Elaine Banks

WOW!
Thank you so much for a comprehensive and well thought out answer. It was very useful and a joy to read.
EB
20 years ago
I am asking:
1) What would be the best way to validate the user input matches the allowable values?

Thanks,
CB
20 years ago
I hope you are all well this evening. I am working ahead for my next course and find that programming is alot more fun without an assignment due on a specific day.
Anyway...
Here's what I'm working on tonight:

=============================================
Please ignore the stuff I have commented out...I may try and use dialog boxes after I get the main logic of the program working....
Anyway...for this assignment there are only supposed to be three valid choices for wages and three valid choices for hours worked. The wages are $7.00, $10.00 and $12.00 per hour. Number of hours are either 40,45 or 50.
What would be the best way to build error checking into this program? All suggestions welcome. Thanks in advance.
Happy New Year to All!
EB
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ January 07, 2004: Message edited by: Dirk Schreckmann ]
20 years ago
Muchas Gracias.
You guys are the best!!
EB
20 years ago
public class pool
{
static final int RATE_OF_FLOW = 50;
static final float CAPACITY = 7.5f;
void pool (int L, int W, int D)
{
int volume = (L * W * D);
float time_to_fill = (L * W * D * (CAPACITY/RATE_OF_FLOW*60));
float pool_capacity = L * W * D * CAPACITY;

}

public static void main (String [] args)
{
pool smallPool = new pool (20,12,4);
pool largePool = new pool (30,20,10);

}
}
All input welcome.
Thanks.
EB
20 years ago
Talk about a big fat DUH on that one....
Good Grief...look right past the obvious on that one! No main()!!!
It's obviously time for bed.
nite nite.
CB
20 years ago
Happy Holidays, All!
Okay - what am I doing wrong here:
I have two classes, Employee1 and EmployeeMaker:
======================================================
public class Employee1
{
private String firstName;
private String lastName;
private int empID;
private float salary;
//get and set for firstName
public String getFirstName ()
{
return firstName;
}
public void setFirstName (String firstNameIn)
{
firstName = firstNameIn;
}

//get and set for lastName
public String getLastName ()
{
return lastName;
}
public void setLastName (String lastNameIn)
{
lastName = lastNameIn;
}
//get and set for empID
public int getEmpID ()
{
return empID;
}
public void setEmpID (int empIDIn)
{
empID = empIDIn;
}
// get and set for salary
public float getHourlyWage ()
{
return salary;
}
public void setSalary (float wageIn)
{
salary = wageIn;
}
public Employee1 ()
{
firstName = "Unknown";
lastName = "Unknown";
empID = 0;
salary = 0.00f;
}
public Employee1 (String firstNameIn, String lastNameIn, int empIDIn, float salaryIn)
{
firstName = firstNameIn;
lastName = lastNameIn;
empID = empIDIn;
salary = salaryIn;
}
} //end of class
========================================================
public class EmployeeMaker
{
Employee1 employee101 = new Employee1 ("Kim", "Yee", 101, 40000.00f);
Employee1 employee102 = new Employee1 ("John", "Reynolds", 102, 55000.00f);
Employee1 employee103 = new Employee1 ("Elena", "Gonzales", 103, 50500.00f);
Employee1 employee104 = new Employee1 ("Jim", "OShea", 104, 75000.00f);
System.out.println (employee101.getLastName());
}
===========================================================
Why will that last line not compile? What's wrong with
System.out.println (employee101.getLastName());
???
Someone enlighten me please!
EB
20 years ago
I appreciate your help very much, and when I cut, pasted, compiled and ran the program it did not output the "doctor" part.
Merry Merry Christmas.
EB
20 years ago
Now I've modified it to include the initials...but it still doesn't add the full degree name....
EB
20 years ago
Thank you a million times.
However, in the println - the name needs to print with the degree initials as well as the degree spelled out too.
i.e. Catherine G Banks PhD Doctor
The way you've written it it only outputs the name...no initials or degrees.
EB
20 years ago
Well...I've messed around with putting them in different classes...I had them in "student" to start with. You're right...that line won't compile...
Here...I'll post with that stuff moved over to the student class.
public class Banks_Student
{
private String firstName;
private String middleInit;
private String lastName;
public String degreeInit;
String [] [] degreeList = {
{"AS", " AA", " BS", " BA", " MS", " MA", " PhD"},
{"Associate of Science", "Associate of Arts", "Bachelor of Science", "Bachelor of Arts", "Master of Science", "Master of Arts", "Doctor"}
};
public Banks_Student (String firstNameIn, String middleInitIn, String lastNameIn, String degreeInitIn)
{
firstName = firstNameIn;
middleInit = middleInitIn;
lastName = lastNameIn;
degreeInit = degreeInitIn;
}

public StringBuffer getFullName ()
{
StringBuffer wholeName = new StringBuffer ();
wholeName = new StringBuffer().append(firstName).append(middleInit).append(lastName).append (degreeInit);
return wholeName;
}
public String addTitle(String title)
{
for (int i=0; i<7; ++i)
if (degreeList[0][i].equals(title))
{
title = degreeList [1] [i];
break;
}
return title;
}

}
=================================================================
public class Banks_CreateStudent
{

public static void main (String [] args)
{

Banks_Student student1 = new Banks_Student ("Catherine ", "G ", "Banks ", "PhD ");
Banks_Student student2 = new Banks_Student ("Average ", "A ", "Joe ", "AA");
System.out.print (student1.getFullName());
//System.out.println (student1.addTitle());
//I have this commented out because it will not compile.
}
}
====================================================
What do I need to do to print out the title spelled out next to the degree initials?
EB
20 years ago
Okay - Here is the class called "Student"
public class Banks_Student
{
private String firstName;
private String middleInit;
private String lastName;
public String degreeInit;
public Banks_Student (String firstNameIn, String middleInitIn, String lastNameIn, String degreeInitIn)
{
firstName = firstNameIn;
middleInit = middleInitIn;
lastName = lastNameIn;
degreeInit = degreeInitIn;
}

public StringBuffer getFullName ()
{
StringBuffer wholeName = new StringBuffer ();
wholeName = new StringBuffer().append(firstName).append(middleInit).append(lastName).append (degreeInit);
return wholeName;
}
=========================================================================
...and here is create student
public class Banks_CreateStudent
{
String [] [] degreeList = {
{"AS", " AA", " BS", " BA", " MS", " MA", " PhD"},
{"Associate of Science", "Associate of Arts", "Bachelor of Science", "Bachelor of Arts", "Master of Science", "Master of Arts", "Doctor"}
};
public String addTitle(String title)
{
for (int i=0; i<7; ++i)
if (degreeList[0][i].equals(title))
{
title = degreeList [1] [i];
break;
}
return title;
}
public static void main (String [] args)
{

Banks_Student student1 = new Banks_Student ("Catherine ", "G ", "Banks ", "PhD ");
Banks_Student student2 = new Banks_Student ("Average ", "A ", "Joe ", "AA");
System.out.print (student1.getFullName());
System.out.println (student1.addTitle());
}
}
The goal is to print out the whole name along with the degree initials and the degree spelled out. It goes along fine until the "degree spelled out" part. Am I even barking up the right tree? How do I pass the "degreeInit" value to the addTitle method?
Many Thanks in Advance,
EB
20 years ago
<Joey Dance>
WHOOOOOOOOOOOOOOOOOOOOOO HOOOOOOOOOOOOOOOOOO!!
</Joey Dance>
Thank you to one and all!
EB
20 years ago
public class Employee
{
public String ssnToName(String ssn)
{
String employeeName = "";
String [] empArray = {"Mary Lou Buford", "Billy Bob Jackson", "John Doe", "Jane Doe", "Sally Jo Pitkin"} ;
String [] ssnArray = {"111111111", "222222222", "333333333", "444444444", "555555555"};

for (int i=0; i<5; ++i)
{
if (ssnArray[i].equals(ssn))
{
employeeName = empArray[i];
}
else
{
employeeName = "No such employee";
}
}
return employeeName;
} //end of SSNToName
}//end of class
Why does this not work?
EB
20 years ago
Never mind...you can call off the suicide watch...
Please understand how fried my feeble brain is.
Thank you so much for your help.
Sure to be back,
EB
20 years ago