Java help - DodgeIntrepid.Net Forums - Dodge Intrepid, Concorde, 300m and Eagle Vision chat
 
LinkBack Thread Tools Rate Thread Display Modes
post #1 of 8 (permalink) Old 02-09-2008, 11:33 AM Thread Starter
MU Alum in da House
 
skotty4prez's Avatar
 
Join Date: Dec 2006
Location: Huntington,WV
Posts: 284
Feedback: 0 / 0%
                     
Java help

I know there are some programmers in here. I am starting my core classes and one of them is intro programming class with Java.

I am starting to get the hang of what does what, but I really would like some more help with just the basics. The book I have isn't too much help if you ask me and the professors are good but I just don't have a lot of time in class and their office hours are not feasible because of my other classes.

So, is there anyone here that can help me out with this or point me somewhere besides another forum to get advise and stuff like that?

Thanks a lot again.
skotty4prez is offline  
Sponsored Links
Advertisement
 
post #2 of 8 (permalink) Old 02-10-2008, 08:57 AM
Intrepid Modder
 
Starnerf's Avatar
 
Join Date: Feb 2005
Location: Rochester, NY
Posts: 636
Feedback: 2 / 100%
                     
I'll do my best to help. I'm a 3rd year Software Engineer.
Starnerf is offline  
post #3 of 8 (permalink) Old 02-10-2008, 10:15 AM Thread Starter
MU Alum in da House
 
skotty4prez's Avatar
 
Join Date: Dec 2006
Location: Huntington,WV
Posts: 284
Feedback: 0 / 0%
                     
OK. As I said I am in an intro Java class and I am having trouble typing some code.

/**
* Write a description of class Month here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class Month
{
public static void main (String[] args)
{
String monthString = "JanFebMarAprMayJunJulAugSepOctNovDec";
Scanner myScanner = new Scanner (System.in);
System.out.print ("Enter a month: ");
int mon = myScanner.nextInt();
System.out.println ("The month is " + monthString.subset (start, end));
start = end - 1;
end = start * 3;

System.exit(0);
}
}


This is the code I am using. What I am doing is trying to get the month to display whenever you enter a number for the month in. Like entering 1 will give you an output of Jan and so on for the other months. I get an error message when I compile it on this line here:
System.out.println ("The month is " + monthString.subset (start, end)); and it says error on the variable start. Maybe something else in the code is wrong, I dunno. I do know that the start and end variables are wrong, I was trying to do this in the morning so I know I need to fix that but I need to get the above fixed first.
Maybe you can help me out like this. I just need to know how I can tell what I need to type out.
Thanks for helping.
skotty4prez is offline  
Sponsored Links
Advertisement
 
post #4 of 8 (permalink) Old 02-10-2008, 05:15 PM
Intrepid Modder
 
Starnerf's Avatar
 
Join Date: Feb 2005
Location: Rochester, NY
Posts: 636
Feedback: 2 / 100%
                     
You're using "start" and "end" before you define them. You need to give them a value before you can use them.
Starnerf is offline  
post #5 of 8 (permalink) Old 02-12-2008, 10:07 PM Thread Starter
MU Alum in da House
 
skotty4prez's Avatar
 
Join Date: Dec 2006
Location: Huntington,WV
Posts: 284
Feedback: 0 / 0%
                     
Thanks for the help. I was suppose to go to my professors office this morning but there was a 2 hour delay so there went that plan.

Good news though. I finally managed to get to to run with out errors. The bad part is that it will not display what I want it to. I am probably just thinking aout it all wrong. Tomorrow I will see if I can get some help. Thanks again.
skotty4prez is offline  
post #6 of 8 (permalink) Old 02-13-2008, 09:18 AM
Intrepid Modder
 
Starnerf's Avatar
 
Join Date: Feb 2005
Location: Rochester, NY
Posts: 636
Feedback: 2 / 100%
                     
You should define start and end as follows:

int start = (3*mon) - 3;
int end = start + 3;

And put these declarations before the print statement.
Starnerf is offline  
post #7 of 8 (permalink) Old 02-13-2008, 10:29 AM Thread Starter
MU Alum in da House
 
skotty4prez's Avatar
 
Join Date: Dec 2006
Location: Huntington,WV
Posts: 284
Feedback: 0 / 0%
                     
Thanks....I was trying to figure out exactly how to do this yesterday. I spent the better part of an hour before class and was getting there. I had the end correct but was having a lil trouble with the start.

You are now my new best friend. + Rep for you!!!!!!
skotty4prez is offline  
post #8 of 8 (permalink) Old 02-13-2008, 11:06 AM
Intrepid Modder
 
Starnerf's Avatar
 
Join Date: Feb 2005
Location: Rochester, NY
Posts: 636
Feedback: 2 / 100%
                     
No problem.
Starnerf is offline  
Sponsored Links
Advertisement
 
Reply

Quick Reply
Message:
Options

Register Now



In order to be able to post messages on the DodgeIntrepid.Net Forums - Dodge Intrepid, Concorde, 300m and Eagle Vision chat forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.

Member names may only be composed of alpha-numeric characters. (A-Z and 0-9)

!!ATTENTION ADVERTISERS!! If you intend on advertising anything on this forum, whatsoever, you are required to first contact us here . Additionaly, we do NOT allow BUSINESS NAMES unless you are an Authorized Vendor. If you own a business, and want to do sales on this site via posting or private message, you will need to follow the rules. Shops, Stores, Distributors, Group Buys without being authorized will see your account terminated.

User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.

Password:


Confirm Password:
Email Address
Please enter a valid email address for yourself.

Email Address:
OR

Log-in










Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes Rate This Thread
Linear Mode Linear Mode
Rate This Thread:



Posting Rules  
You may post new threads
You may 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

 
For the best viewing experience please update your browser to Google Chrome