Tim Mannion

Greenhorn
+ Follow
since Dec 19, 2011
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tim Mannion

Thanks. That's what I was thinking but how would I convert the "1/2" string to a ".5" double. I was thinking of a series of if(string == "1/2") x = .5; if(string == "1/4") x = .25; etc etc because in recipes basically everything is 1/2, 1/4, 3/4, 1/3, or 1/8ths but I feel like the application will work better if it were able to convert it itself.

~Tim
12 years ago
So I've been going through a textbook teaching myself java and I've started on building my first application that's not an exercise in the book. What I'm trying to do is create a recipe book type thing where you can store recipes. I want the user to input the ingredients one by one but I want the program to divide it into a double for the amount, a String for units, and another string for the actual ingredient. For example, if someone puts in "1 1/2 cups flour" I want it stored as 1.5 for amount, cups as the unit, and flour as the ingredient. I want to do this so I can eventually make it so if you want to halve the recipe it can adjust the amounts itself. I'm having trouble figuring out how I can separate each part. This is the method I've been working on but I'm sure someone out there will be able to help me understand an easier way to do this. Please let me know if I'm not explaining this well.

~tim

12 years ago
Thanks so much that helped alot!
12 years ago
Fairly new to java here....teaching myself through a text book...I asked a couple questions on here before and found it real helpful. hope someone can tell me what I'm doing wrong.
Basically I'm supposed to create an application that creates an array of 10 Student objects each of which have 5 Class objects then display the grades. It compiles fine but once I add the first student array terminal says "Exception in thread "main" java.lang.NullPointerException
at InputGrades.main(InputGrades.java:14)"
can anyone explain my mistake to me?


i didn't include my displayResults method to save room/didnt think it mattered.
12 years ago
THANK YOU ALL SO MUCH FOR THE ADVICE! Here's my final code and it seems to be working fine. Thanks Matt for pointing out that I forgot to reset my variables!

12 years ago
Thanks for the help from everyone. This forum seems really awesome and helpful but I'm still having some trouble with this problem

Paul Clapham wrote:
That's right, that's what it is. But your code doesn't involve division or remainders in any way; this is a big hint about why it isn't producing the output you want.



Thanks for that tid bit I totally felt like a fool when I realized I didn't include any % statement but now I added one and it still won't print anything


12 years ago
So I decided I wanted to teach myself to be a computer program with little to none prior experience. I borrowed a text book one of my friends had (Java Programming 5th ed by Joyce Farrell) and I'm working my way through it. I'm on chapter 6 and I'm stuck on a problem......I just learned how to make loops in this chapter and the problem asks me to print every perfect number from 1 - 1000 and explains that a perfect number is a number where all the numbers that divide evenly into it add up to the original number (like 6 and 28) I worked out a code that I think should work but it's not printing anything (it compiles with no error). Can anyone tell me what I'm doing wrong? here's my code so far:

EDIT: it wont let me format it with my indentations but you should be able to read that anyway i would think

(added by moderator Jesper: You can use code tags to get your source code nicely formatted. I've added them for you above).
12 years ago