November 10th, 2002, 09:40 PM
|
#1 (permalink)
|
| Ultimate Member
Join Date: Oct 2001 Location: Pasadena, CA
Posts: 2,152
| How the heck is this gonna work..... Code: String fname = "Cameron";
String lname = "Doherty";
Calendar c1 = new GregorianCalendar();
Date d1 = new Date("1/20/02");
c1.setTime(d1);
int days = c1.get(Calendar.DAY_OF_YEAR);
String fdays;
if (days <= 9) fdays = "00" + days;
else if (days <= 99) fdays = "0" + days;
else fdays = "" + days;
while(??????)
{
} Ok the problem goes like this. I am making a block of code that will take the entered first name, last name, and date and convert it into a tracking code. So for instance. The above code would be printed out into a tracking code of CD0208. The code has to be 6 characters in length and the last number HAS to have the day of the year number add up to something that ends in 0. For instance, 1/20/02 is the 20th day of the year, so that will be show in the code, as shown before, as 020. 0+2+0 = 2. So to make those numbers have a sum that is divisble by 10, we have to add 8. Hence the final code is 0208. Making sense? hehe. Its a strange requirement from my teacher but whatever. So obviously it will be a loop but Im having trouble figuring out a suitable tester for the loop(to test after each run through of the loop)...hence the ????? in the posted code. Also is this more suitable in a for loop?
So just wanted to get some ideas from some more experienced users  Thanks in advance.
__________________
YAH! I knew you'd be jealous
|
| |