Go Back   Midmoriders.com Mid Missouri Motorcycle Forum > General Forums > Off-Topic

Off-Topic Anything and everything off topic.

Off-Topic Thread, Does anyone know Java? in General Forums; I've got a Java assignment due on Sunday night, problem is, i'm going out of town Friday afternoon for the ...
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 09-01-2010, 07:36 PM
earz's Avatar
Legend
 
Join Date: Apr 2008
Location: Jefferson City, MO
Posts: 1,965
earz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to all
Default Does anyone know Java?

I've got a Java assignment due on Sunday night, problem is, i'm going out of town Friday afternoon for the weekend and will not be around a PC.

I'm stumped and need some help. Let me know if you can help me out.
__________________
1979 Yamaha XS650 - new project
1985 Yamaha XJ700
1982 Yamaha XJ650 - SOLD!!
2003 Kawasaki ZX6- R - SOLD!!
1989 Yamaha TW200 (SOLD)
Reply With Quote
  #2  
Old 09-01-2010, 08:05 PM
FalxZZR's Avatar
Legend
 
Join Date: Apr 2008
Location: Jefferson City
Posts: 4,779
FalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond reputeFalxZZR has a reputation beyond repute
Send a message via AIM to FalxZZR
Default

my java is limited to rotating banners at the top of a forum~
__________________
''The man hunched over his motorcycle can focus only on the present instant of his flight; he is caught in a fragment of time cut off from both the past and the future; he is wrenched from the continuity of time ... in other words, he is in a state of ecstasy; in that state he is unaware of his age, his wife, his children, his worries, and so he has no fear, because the source of fear is in the future, and a person freed of the future has nothing to fear.''
www.myspace.com/midmoriders
Reply With Quote
  #3  
Old 09-01-2010, 09:58 PM
Full Leathers
 
Join Date: Aug 2010
Location: in a tree
Posts: 227
RebelKittyn is getting up to speed
Default

i know bits and pieces, depends on what you're trying to do. did this little 'into to javascript' during my html classes junior and senior year and took C++ programming my freshman year of college, but those have been a couple years at least.
__________________
~"Have you ever noticed that 'lol' looks like a drowning guy? I bet he's not laughing out loud."
~"Blaming a shooting on a gun is like me blaming my spelling errors on my keyboard."
~YouTube- Over Powered Powerwheels Snow Jam Barbie Jeep vs. Corvette vs. F150 vs. Mustang Crazy Drift
Reply With Quote
  #4  
Old 09-01-2010, 11:02 PM
earz's Avatar
Legend
 
Join Date: Apr 2008
Location: Jefferson City, MO
Posts: 1,965
earz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to all
Default

I think javascript may be slightly different than java - but I'm new to it so I may be wrong. Anyway.

I'm trying to get it to capitalize the first word of a sentence. I can get it to capitalize every word (see code below), but I just want the FIRST word of a sentence. When the user enters:

hello, how are you today? i'm doing great!

I want it to display:

Hello, how are you today? I'm doing great!

Here's what I've got so far. I'll add the Scanner class later to accept a users input. Right now I just have a string initialized for testing purposes. I have been working on and thinking about this for two days. I've tried so many variations that I'm going cross eyed. At one point, I had it working except it didn't space between the ending punctuation mark and the next word, but couldn't figure out how to add the space in - but now I don't remember what all I changed.

Code:
public class CapitalizeFirst {

	
	public static void main(String[] args) {
		String test = "hello, how are you today? ";
		
		System.out.print("Original: " + test);
		System.out.print("\nNew: " + title(test));

	}
	
	public static String title(String string){
	
		for(int i = 0; i < string.length(); i++){
			
			if(i == 0){
				string = String.format("%s%s", Character.toUpperCase(string.charAt(0)), string.substring(1));}
			
			if(!Character.isLetterOrDigit(string.charAt(i))){
				if(i + 1 < string.length()){
					string = String.format("%s%s%s", string.subSequence(0, i + 1), 
							Character.toUpperCase(string.charAt(i + 1)), string.substring(i + 2));
					}
				}
		}
		return string;
	}

}
__________________
1979 Yamaha XS650 - new project
1985 Yamaha XJ700
1982 Yamaha XJ650 - SOLD!!
2003 Kawasaki ZX6- R - SOLD!!
1989 Yamaha TW200 (SOLD)
Reply With Quote
  #5  
Old 09-02-2010, 10:56 AM
Full Leathers
 
Join Date: Aug 2010
Location: in a tree
Posts: 227
RebelKittyn is getting up to speed
Default

I'm guessing you're trying to code a program that checks/corrects spelling/grammer errors? Not sure if there's a specific code for it, but I would think you could use and if then function.

If First=lowercase
Then CapitalizeFirst


You would prolly have to enter a string somewhere that would cause it to recognize the first letter and I don't know if it would recognize lowercase or capitalize as objects/commands. if it didn't then it'd be a looong bit of typing...

if First=a
then substitute A

I still have my C++ programming book from College, I'll have to take a look at it sometime tomorrow. If anything useful does pop up, you're welcome to borrow it. Heck I've still got the program given to us to use for the class.
__________________
~"Have you ever noticed that 'lol' looks like a drowning guy? I bet he's not laughing out loud."
~"Blaming a shooting on a gun is like me blaming my spelling errors on my keyboard."
~YouTube- Over Powered Powerwheels Snow Jam Barbie Jeep vs. Corvette vs. F150 vs. Mustang Crazy Drift

Last edited by RebelKittyn; 09-02-2010 at 10:58 AM.
Reply With Quote
  #6  
Old 09-02-2010, 11:19 AM
earz's Avatar
Legend
 
Join Date: Apr 2008
Location: Jefferson City, MO
Posts: 1,965
earz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to allearz is a name known to all
Default

Thanks, but I was up until 4am, but figured it out.
__________________
1979 Yamaha XS650 - new project
1985 Yamaha XJ700
1982 Yamaha XJ650 - SOLD!!
2003 Kawasaki ZX6- R - SOLD!!
1989 Yamaha TW200 (SOLD)
Reply With Quote
Reply

Thread Tools
Display Modes

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

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



All times are GMT -6. The time now is 07:00 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0