home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2874
Discussions: 188,380, Posts: 2,243,464, Members: 232,608
Old November 10th, 2002, 09:40 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Tekk's Avatar
 
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

Tekk is online now   Reply With Quote
Old November 10th, 2002, 09:46 PM     #2 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
Forgot...I was converting it to a string so I could add the necessary 0's and also so that when I wanted to add up all the individual digits....I could just use:

int a = Integer.parseInt(fdays.substring(0,1));

and so on.

Tekk is online now   Reply With Quote
Old November 12th, 2002, 03:06 AM     #3 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
figured a workaround...no loop needed

Code:
if ( (a+b+c) >=11) digit = 20 - (a+b+c);
else digit = 10 - (a+b+c);

Tekk is online now   Reply With Quote
Old November 12th, 2002, 12:56 PM     #4 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 21,019
no wonder I was so confused at the syntax of the writing its java lol
I was reading it like it was VB ya ya I'm pathetic I know lol
vass0922 is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2885)
The United States Debt (20)
Looks like Burris will get his Sena.. (8)
I think I just killed my computer w.. (24)
Upgrading RAM (5)
Folderchat Weekday thread (439)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (14)
Help with an Ati Radeon HD 4850 512.. (25)
Recent Discussions
Building a gaming computer advi.. (1)
Best digital camera for under 2.. (14)
Help with an Ati Radeon HD 4850.. (25)
Install Problem for Windows Def.. (0)
New Build ( Finally ) (1)
dual monitors wont boot (0)
Folderchat Weekday thread (439)
MSN Hotmail Down??? (7)
Laptop waking up itself (0)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 08:45 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28