George McCoy

Greenhorn
+ Follow
since Apr 11, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by George McCoy

And I'm back. :/ So, I'm writing a class file that interacts with a driver to get a student's info but I'm having a bit of trouble with the input validation. Basically, if I enter any ID number via the driver that doesn't start with the letter E, then the ID number should be set to the default value of E####### and if the concentration isn't CS, IT or IS, it's supposed to default to XX. But lines 17 and 29 keep throwing me the error message "Incomparable types: char and String" and the default values don't kick in so when I run the print statements in the driver, it displays an ID of "Not a valid ID" and a concentration of "Messing up Java programs" that I entered with the driver. I have no idea why it thinks there any chars in there since I declared everything as Strings. Any idea where I messed up and how to fix it?

Here's the class file:


And the driver:
7 years ago
I knew it was something I'd feel really dumb about afterwards. :/ That's what I get for trying to code before my first cup of coffee. Thanks!
7 years ago
I'm trying to get a student's classification based on their completed hours but I keep getting errors. I'm kind of embarrassed asking about this since I can usually do if/else if statements with no problem but lines 5 and 8 give the errors "Illegal start of expression" and I have no idea why. I've declared the hoursCompleted and classification variables so that's not the problem.
7 years ago
I just finished this project but I'll probably need help in the future. Thanks!
8 years ago

Knute Snortum wrote:And Welcome the the Ranch. Would you like to post what you did?


Sure. I changed to and now it's working. I guess I should have posted the entire thing after all since I left out the part where I name the order. Oops. You all probably would have figured it out but it was still kind of dumb of me to forget that.
8 years ago
Never mind. I figured it out. Feel free to lock/delete this.
8 years ago
So, I'm working on an assignment where I have to call methods, setters and getters from a class file called CustomerOrder. CustomerOrder was written by the professor and I have to use the javadocs to decide what methods and stuff to use. The only problem I'm having is with the method calcDiscount. The javadocs info is:

Method name: calcDisocunt()
Returns: double
Purpose: Calculates the user's discount based on their discount status.


This is just the snip of code I'm having trouble with but I can post the entire thing if you want. It's kind of long and everything else is working so I didn't want to clog up the page unnecessarily.



The line

CustomerOrder.calcDiscount();

keeps giving me the error "non-static methods cannot be accessed from a static context." Any idea how to fix it? Obviously my main method is static so should I change that? I've never done that before though so I might need a bit of help if that's the solution.
8 years ago