sillyboy 43 Practically a Master Poster

nope, before main you will see "def". This means that everything within the block (in jython the block will be defined with indenting) belongs to "main". So you need to define your functions accordingly to be able to recall specific activities. You can make your life easier by choosing well defined function names and making sure they only do what is expected of them.

Hope that clarifies it a little for you...

sillyboy 43 Practically a Master Poster

Ok, so your program is going to end when it has no code left to execute (which you probably already know). For you to get the behaviour explained above, you will probably need to execute parts of the code more than once. Anyway, with the code you posted before, when the user is correct (or whatever your condition is), you can simply call "main()" and it will go back to the start.

sillyboy 43 Practically a Master Poster

That looks great, I ran it quickly and it works well.

You shouldn't look to me for directions, they are in your problem definition. If I were solving this problem, I would probably next look at reading a user input to determine the difficulty. So you could have 3 pre-defined problems, and decide which to show the user depending on the difficulty they select. Good luck

sillyboy 43 Practically a Master Poster

Ok, well you not going to be convincing me to do your assignment for you, but I am happy to help. Once you start producing code, I can help you with more specific issues.

Anyway, basic of basics: write a hello world program, and append some user input on the end. e.g. "hello world, [user input]". Reading in the user input is a large portion of the problem you need to solve, if you need syntax, google will be your fastest companion. Try that first...

sillyboy 43 Practically a Master Poster

Leave the graphics till last. First, create a program which is able to read / write to the command-line e.g. ask a question, recieve an answer. If you get that working, adding the random aspect and difficulties shouldn't be too hard.

sillyboy 43 Practically a Master Poster

If you can work out what sound card you have, you can search for its drivers. If you think you already have some old drivers installed, check by Right-Clicking my computer > properties > hardware > device manager > sound, if you select your sound device you will be able to update drivers.

sillyboy 43 Practically a Master Poster

Nice work, you can mark the thread as solved so that people know too.

sillyboy 43 Practically a Master Poster

If you are hosting over the internet, your local IP address won't work because it is "local". I think you can try the router ip + port instead... not 100%

sillyboy 43 Practically a Master Poster

As a temporary measure you could try use OpenOffice instead (free office suite). Unfortunately I don't really have a solution to your problem, I would suggest google, or hopefully somebody else can help you out.

sillyboy 43 Practically a Master Poster

For staters, you don't need to be using floats for hour, sec, min and this is where a lot of your issues will be starting.

If you avoid decimal multiplication / division, you will probably get results closer to what you want. e.g. 1.20 = 1 in int (I am referring to your hours).

After you calculate hours, you need to take this into account when calculating the minutes. After you get the minutes you need to take this & hours into account when you calculate the seconds.

Hope this helps...

sillyboy 43 Practically a Master Poster

src="/default.asp?client='$query_value'"

I can not use any server side code!

I think you have broken your own rule already since asp is server-side. Anyway, what you probably want to do is look at AJAX.

sillyboy 43 Practically a Master Poster

I would take that as three scenarios. Is there a shorter way? Most likely, but I wouldn't think that is the aim here, and I wouldn't be the best person to try optimise your code.

Perhaps somebody else can help you there...

sillyboy 43 Practically a Master Poster

Well yes you would probably end up needing another try / catch block. Keep in mind though, a scenario is like a story.

To test some other cases, perhaps have a movie where ALL the humans watch the movie, and one where NONE watch the movie.

Does that make sense?

sillyboy 43 Practically a Master Poster

Regarding requirement 1, not too sure exactly what the issue is, and I am not too sure what the family class looks like. Your conditions are also redundant (you are checking the same condition for each case, so you don't really need to divide these out).

Regarding the second requirement, it seems you already have 1 scenario, so just add more.

Hope that helps

sillyboy 43 Practically a Master Poster

From what I've read it is working for everybody except you...:(

What IDE are you using to program, compile, run this code? Can you give some details on your inputs etc...

Send me you code if you want and I will try it without touching it at all.

sillyboy 43 Practically a Master Poster

I copy / pasted your original code and added (double) in the divisions, this is the output I got (looks like it works to me):

Grades Program

Enter valid student grades (in decimal values ranging from 0-100).
Invalid grades will not be considered. Enter -1 to view the results.


	Input a grade: 99
	Input a grade: 85
	Input a grade: 70
	Input a grade: 60
	Input a grade: 50
	Input a grade: 40
	Input a grade: 30
	Input a grade: -1


Your Results:


The total amount of valid grades input were: 7

Letter Equivalent	Instances	% of total	
	As:		1		14.285714285714285%
	Bs:		1		14.285714285714285%
	Cs:		0		0.0%
	Ds:		1		14.285714285714285%
	Fs:		4		57.14285714285714%

	pass:		3		42.857142857142854%
	fail:		4		57.14285714285714%

The highest valid grade you entered was: 99.0
The lowest valid grade you entered was: -1.0

The average of the valid grades you entered is: 62.0
sillyboy 43 Practically a Master Poster

That looks correct, so if it isn't working I fear you probably have some silly mistake somewhere else :p

This is a simple test program I wrote:

public class Main {
	
	public static void main(String [] args) {
		
		double result;
		
		int value = 50;
		int count = 100;
		
		result = ((double)value / count) * 100;
		
		System.out.println(result);
	}

}

Console output:

50.0
sillyboy 43 Practically a Master Poster

Give a heads up if you get too stuck.

sillyboy 43 Practically a Master Poster

Hey, I think you are on the right track with your percentages. So by it not working, I assume you get getting results of 0% for everything?

If this is indeed the case, the problem is int / int is integer division, and will return a int. So... since counter is always greater than your percentage, it is always 0.XYZ which will get trimmed to be 0. Since you are keen to learn and put in the effort, you should be able to find a solution to this :).

In regard to having string inputs, sure you will be able to do this. But if you decide to take this route, you may need to learn some exception handling... I am not too sure how strict your requirements for the assignment are and it seems you are already going beyond the scope, so perhaps you won't need exception handling.

hope I have helped...

sillyboy 43 Practically a Master Poster

Pretty much worked straight away for me. All I did was create a new project, delete the default package and copy in your package instead. DoodleBug.java was missing a package statement, but that was all...

You still having issues?

Alex Edwards commented: Thanks a million for your help! +1
sillyboy 43 Practically a Master Poster

Yeah, you will definitely need the package declarations. It is hard to tell what is going on though, so you have a specific error you can paste? (try google too).

sillyboy 43 Practically a Master Poster

You want to add a library, or just source files to edit? If it is a library (.jar) or something, there should be an add external library option. But I think you want to add source files, you can just drag-drop or do it directly in the filesystem.

sillyboy 43 Practically a Master Poster

Watch your blocks as I think you are missing a few { }.

I would do it slightly different to you, but this is how I would do it:

function confirmSubmit() {
        var acc = document.getElementById("accept");
	if (!acc.checked) {
		alert("You must agree with the above items in order to utilize the statistics form.");
		return false;
	} else {
		return true;
	}
}

For this to work with your code, just make sure you set the id for your checkbox to "accept".

sillyboy 43 Practically a Master Poster

move you window redirecting code to a javascript function. Make your onclick call a function to validate the checkbox (again, in javascript), and then if the checkbox is checked you can then redirect.

Actually looking at your code, you seem to be mixing 2 approaches. You do not actually need the onclick if you set the input type to "submit" and the form action to "nflStats.html". Using this will trigger your confirmSubmit function too.

So there are 2 approaches you can take, I suggest you take the latter one I have mentioned.

sillyboy 43 Practically a Master Poster

I'm assuming it would be via the onclick event

Have you tried:

window.location = "???.html";
sillyboy 43 Practically a Master Poster
cout << table[row][column];

Are you sure this is what you want to be doing?
In regard to implementing the random integers, you can just assign them as you print that particular cell. So add something before the above code.

On a minor note, why are you creating an array of doubles?

sillyboy 43 Practically a Master Poster

the easiest solution is to just use scriptlets on the page the form is forwarded to. If you want to use jsp correctly, you should not use scriptlets but instead move this code to java classes.

sillyboy 43 Practically a Master Poster

So if you want to show the value of the rolls individually, you will want something like:

System.out.println(rollcount);

I'll let you figure out where to put it, but it shouldn't be too hard.

sillyboy 43 Practically a Master Poster

I appologise about the ^2, you are correct here. I assume those "2"s are supposed to be in superscript :). Anyway I felt nice so:

#include <iostream>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
int main() {
    long int terms, count;     
    long double pi = 0;
    
    cout << "Enter the number of terms to use:   " << endl;
    cin >> terms;
    
    for (count=1; count<=terms; count++) {
        pi += (1.0 / (count * count));
    }
    pi = pi * 6;
    pi = sqrt(pi);

    cout << "The approximate value of pi is:   " << pi << endl;

    return 0;
} // end main

You will probably want to put you system pause back in, but that should do what you want.

sillyboy 43 Practically a Master Poster
pi = sqrt(6* (1/(1)2 + 1/(2)2 + 1/(3)2+ 1/(4)2 + 1/(5)2 +...... + 1/(n)2))

Ok, so looking at this equation you have the series of summing 1/(n)2 . This is not equivalent to the sum of 1/(n^2).

I did notice you are using sqrt in your code, but 2 points. 1, surely sqrt means square root and not multiplication (the sqrt is also undefined in your code). 2, the sqrt is located outside of the parenthesis indicating it should be the last operation (you currently have *6 as the final operation).

Hope this helps.

sillyboy 43 Practically a Master Poster
for (count =1; count <= terms; count++);

This pretty makes your loop useless, you don't want that semi-colon.

You also need to check the logic behind the steps you take to calculate pi. E.g. I don't see any square root function used.

sillyboy 43 Practically a Master Poster

This problem is most likely related more with your HTML & CSS than the actual JSP code.

sillyboy 43 Practically a Master Poster

cdName() is trying to call a function called "cdName". Elements of string are referenced using [...] (if that is what you want to do). Also, your setter method is pretty much useless, I think you mean cdName = diskName?

sillyboy 43 Practically a Master Poster

This is probably just a case of the professor trying to scare kids by using code in a way it generally won't be used. If your professor does insist that is the answer and won't budge, just listen to his explanation and remember his rules for the duration of the course. After you pass the course, you can go back to using code as it should be used.

sillyboy 43 Practically a Master Poster

My understand in that i++ means the incrementation should be completed after the particular line of code (maybe the printf complicates things). Where ++i means to complete the statement before. So I would have thought the result should be 5, 5, 5 and then i++-- ... which is just 'i=5' before the next line of code.

EDIT: Well this got me curious, GCC gave me 6, 6, 5 as others have suggested.

sillyboy 43 Practically a Master Poster

Ok, you definitely need a return. If you didn't want a return you would say "int main()", but even with main it is advised you do return. I haven't tested your particular segment of code and I don't think I will, but it looks like it would get the desired result. If you want to think about this more, you should think of a more elegant solution (e.g. do you really need another variable int i? etc.) Also, I think "srand" used by Aia is a better solution.

sillyboy 43 Practically a Master Poster

Jaav a couple issues with that code:
1. you have an impossible condition inside that while loop.
2. rnd is initialised after it's use.