JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please post the exact full error message. and someone will explain it for you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't know where to start

The assignment is broken down into steps for you, but you can break it down further. Start with

reads the grades from a user. The format of a grade line is: ...

just do that, one step at a time. Read in one line of data and print out what you have read to confirm you have it right. The create a loop so you can read multiple lines (and print out what you have read to confirm you have it right).

Then

All scores must be between 0 and 100.

add code to test for valid input. Try it with valid and some invalid input and print out what you have read to confirm you have it right.

... and so on. Just break it down into the smallest possible steps the code & test each one before moving on.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
  1. AWT and Applet are decades out of date. You should be using Swing and JApplet.

  2. I can't be bothered to load and read your word docx. What exactly is your question here?
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

A 100x100 array of integers is only 40kbytes, so that's perfectly feasible in most environments. Just loop through the input keeping one index for the current polygon and one for the current point. Or you may be better advised to use linked lists for the polygons and the points in each polygon if the potential size limits are increased... 100% overhead on the actual points, but no space wasted for unused slots?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do an object oriented analysis and design

Is that right Heather? If so you just wasted a whole load of my time (and yours) by hiding that fundamental requirement.

rproffitt commented: Objects of desire create ire when hidden? +12
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It sounds like you have not covered creating classes in your course yet, so if that's the case it would be a bad idea for me to try to overlap with your real teacher. I would stick to arrays if that's what you know. If there are just two variables for each tree then a 10x2 array is big enough.
The java.lang.Math class has a random method that gives you random numbers between 0 and 1 (see the API doc for details). You just need a bit of simple arithmetic to convert that into a specified range.
I wouldn't worry about saving yet. Solve one problem at a time. Beginners try to write the whole program, then see if it works. When it doesn't work they don't know where to look first. Real programmers break their problem into small steps then code AND TEST each step before moving on. Just google "test early, test often".

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, that's a good start.

Next step is decide how you will represent your forest of trees inside your program. There are 10 trees, and each tree has a height and a growth rate. A Tree class is the obvious Java solution, but if you have not got that far in your lessons then you can use two arrays - one for the 10 heights and one for the 10 growth rates.

Whichever you decide you can declare the necessary class or arrays, and move straight on to the code that displays the data, then the code that creates a new forest by populating it with random values. Don't worry about the other options until you have these two working!

Heather_6 commented: how do you code/create a new class? +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Has your course covered the idera of defining a class? The obvious approach is to create a Tree class with the tree's height and growth rate and the related methods. A Forest is then just a collection (could be an array) of Tree objects. Reaping is just a pass through the collection of trees deleting Tree objects over the given height and replacing them with new Tree objects.

Heather_6 commented: I just commented what I have so far, if this is wrong please help guide me in the right direction. +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

DaniWeb is a resource that everyone can contribute to and everybody can use, so please keep your question in the forum so others can help answer it and more people can learn from it. In any case I don't have any more time right now (bedtime where I live), so you will need someone else to get involved. JC

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, looking back I think I've been diverted by the talk about numbers, and maybe sent you in a wrong direction.

If you want to store the characters of a string in a BI, but you don't care how they are represented inside the BI as long as you can get them back again.. then the byte array will work

        // store string in BI
        String s = "abc";
        byte[] b = s.getBytes();
        BigInteger bi = new BigInteger(b);

        // get it out again
        byte[] bb = bi.toByteArray();
        String ss = new String(bb);
        System.out.println(ss);

... but you won't be able to make any sense of the string when its in the BI.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Just create a new BigInteger using the constructor that takes a String, eg

String s = "123";
BigInteger bi = new BigInteger(s);

System.out.println(bi);
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes. println (and the other similar methods) automatically call toString() for each of the objects they are printing.
BigInteger's toString() method returns a printable version of it's value, just like you would hope.
Trying to do it via a byte array won't work, for exactly the same reasons as converting String to BigInteger via a byte array won't work (see above).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do you have idea if it contains method that generates prime number and the primitive root

That's what the API documentation is for. It lists every public method in the class

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi jaina

Please read the whole topic before replying, especally for threads that are 6 years old.
The original question was about solving the problem using arrays in C++. While what you post is correct, it's (a) 6 years too late and (b) irrelevant.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm not a php user, but just reading what you posted...
these constants have a name and value (which depends on the context).
The name appears to be case-insensitive (ie LINE Line line are all valid), but the values follow case-sensitive rules as above.
Maybe a php buff can confirm or correct that.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Your source code has errors that prevented java from creating an executable class file. You need to read all the error messages from the compiler and fix those before trying to run you program.

rproffitt commented: Concise answer. Find eror, fix error. +12
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

To me that seems like a violation of everything that OO is about. A Circle should know how to tell you its radius, circumference, area etc. Which of those is held as a attribute and which are calculated on the fly, and which are calculated once then re-used etc is a private matter for the Circle. By putting the data in one class and the methods in a separate "Utilities" class you are reverting to the older separated model that OO replaced.

Having said that, I think we are in danger of hijacking Violet's thread for our own discussion. Having each stated our position, maybe we should now let it drop until/unless Violet wants to come back onto any of these points. :) JC.

jkon commented: Yes maybe the Circle example wasn't so good +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I agree with jkon, with the very minor exception that I would be happy to see other methods (more than just get/set) in the Student class, if that's where they fit best.

The createStudent method may be a bit of a red herring... in this app so far it's trivial and just calls a method in the model layer (happens to be a Student constructor). In a more real example it would, as jkon says, deal with data access objects and maybe a student factory to achieve the desired result, so IMHO it's OK to see this version as a kind of placeholder for the real thing.

jkon commented: I am not either 100% to that but if the POJO behavior is changing then it is a utilities class with static methods that take that obj in an argument +9
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do you have a question?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
  1. The View class should just be given a reference to the Model that it will display, then all it needs are public methods like displayDetail() or displaySummary(). It should get the individual fields from the Model as needed.

  2. If you have a Controller then you shouldn't be calling Model or View methods yourself - the Controller should have public task-oriented methods that you call from main or wherever, and the Controller then calls methods in the Model and View as needed.
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

When you create your jar file it's optional whether you include the source code or not. The source code is not needed to run the app, so don't include it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi Viral

This is a web site for people who work with computers and want to learn more. If you want to learn how to write turtle code then start your own topic here and someone will help you. If you just want someone to do it for you then you have come to the wrong place - wo don't do people's homework for them.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

So something like this?

do {

    // process one pass of user input

} while (JOptionPane.showConfirmDialog(
       null, "Do another one?", "Continue", JOptionPane.YES_NO_OPTION) 
                == JOptionPane.YES_OPTION);
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi Ebrahim

Welcome to DaniWeb.

your questions and contributions are very welcome here, but please be aware of the rules and best practices for this site, including:

don't hijack someone else's topic for your question. Start you own topic.

if you have a question, ask it! Simply posting code does not tell us what help you need

So please start your own topic, explain what help you need, and finally format/indent your code properly so people can read it easily.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi Amazing_2

This thread is 8 years old, and not related to your question, so the right people won't see it.

Please start a new topic to ask your question and I'm sure you will get some good answers.

JC
Moderator

rproffitt commented: Good answer. +12
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry. My English is very bad. Please edit my comments, so I learn to speak correctly.

Well, that English is perfect, no edits needed!

In the post itself... just: Each "else if" has unclosed brackets.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Probably mis-matched brackets, but unless you format your code properly it's going to be hard to see.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You forgot

read the user's reply into an int variable.

(use your Scanner)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

With 4x4 matrices I'm surprised you can even measure execution time meaningfully. I'm not surprised that the overheads of a thread pool would greatly exceed the time to do a few array maipulations. I guess each thread will complete within its first time slice.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

is it better to use while() or do{} while?

That depends on what behaviour you want!
while tests the condition before entering the loop. The loop is executed zero or more times
do whiletests the condition after each pass of the loop. The loop is executed at least once.

In any given situation it will usually be obvious which is the more appropriate

ddanbe commented: Well explained. +15
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's not a lot you can do to speed up the loading, buut you can give the impression of a very fast startup by displaying a splash screen while your program is loading. By referencing the spash screen in your jar's manifest Java will display it immediatley, ie even before it starts to load the JVM. Once your program is loading you can draw onto the spash screen to display progress if you want.
It's all explained here...
http://docs.oracle.com/javase/tutorial/uiswing/misc/splashscreen.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This thread is 8 years old and the original poster isn'there now.
Please start a new thread for your project and people will help you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's because you have the if test for even/odd tangled up with the if tests for largest/smallest. Right now you don't get to the even/odd code (lines 20-25) if the number matches either of the if tests on lines 13 and 16.
You need to separate the largest/smallest stuff from the even/odd stuff

if is largest so far ...
else if is smallest so far ...

if is even ...
else ...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Seems to be an implementation of "determinant expansion by minors", so Google that, eg
http://mathworld.wolfram.com/DeterminantExpansionbyMinors.html or
http://paulbourke.net/miscellaneous/determinant/

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's not possible that two return statements in the same method get executed (except if the first is in a try/catch block and throws a caught exception, in which case it starts executing but doesn't finish).
It sounds like one of those trace messages refers to the method from which this one is called? We need to see more of the code.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

At DaniWeb we are all volunteers, here to help people who want to work with us to improve their skills. The more effort you put into that, the more we will want to help. I'm sure you have already thought about how to start that program so please share what you have done so far with us.

ps: all this is explained in more detail in our Posting Rules

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sure, logrotate is a much more comprehensive solution, but I didn't think my simple suggestion was so bad as to deserve a reputation-reducing downvote.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please put the toolbar in the full screen editor.
Some of us stopped memorising bizarre formatting codes when we replaced our DOS 3.2 PCs with a WYSIWYG GUI Mac 128k in 1984.

And another thing...
we are being flooded with new threads that just copy someone's homework question, so we have to refer them to the secret Posting Rules that are hidden in the semi-secret TOS that are in a locked filing cabinet stuck in a disused lavatory with a sign on the door saying 'Beware of the Leopard.” ... after which many of them are frightened off and never seen again
We could save a lot of time if you added another step to creating a new thread to ensure the poster has seen the Posting Rules

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please decide what question you are asking, then maybe someone will be able to give the answer. Your latest post is nothing like the original "save a folder path in the sql server database and retrive it again". In every post you change the question.

So, you are still not giving enough info. "when i click on the folder the program will take the url of the folder" click on it where? On the desktop, in a list box, on a web page??? "take" it in what sense?

Please take the time to describle fully what you are trying to do, in what context, and exactly what it is you don't know how to do.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The URL for a folder is just like the URL for a file except that it doesn't have a file name - it just finishes with the folder name (and its final /). Either way iot's just a string that you can save in a database like any other string.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This thread is tagged Java, so let's assume that is the context.
HashMap in Java is a class in the standard API and it's definitive documentation is here
It's one implementation of the Java API's Map interface - documented here
The definitive Java Tutorials also explain Maps in more detail, and include a section on how to create a multimap. (I don't know why C+ multiimaps should be problematical. In Java they are very common and straightforward.)
Finally - don't ask about the internal implementation of Java Maps - only the public interface is defined so the implementation can, and does, change without notice between Java versions.

rubberman commented: Seems the internet can't find the C++ definition of multi-map now... :-( +14
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

We are all guilty of speaking a kind of shorthand about objects and variables. Most of the time it's OK, but when we talk of call by value etc it really matters.
An object is an object. A variable is not an object and an object is not a variable.
What we call an object variable is correctly a reference variable. It holds a reference to an object (or null).
So "all Java objects are references" is well-intended, but strictly false. It's the variable that's a reference, not the object.

AssertNull commented: Good explanation +7
rproffitt commented: Talk objectively to me. +1 +12
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I have no idea what the answer is, but this post gets my vote as the best question of the decade. If only all our questions were so clear, so well explained, showed so much effort...

I really really really hope someone can help

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, Java always passes parameters by value.
But sorry, your question is not clear. Please explain exactly what you want to know.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

if (n = 1) return 1;

No, not a bug, because yes, that's pseudo-code. Depending on you language you may have to code the test for equality differently (but not, for example in SmallTalk or Pascal). The whole discussion of = vs == in C derivatives is, of course, correct, but not really what this is about.

This recursive algorithm is interesting because you really want to return both the index n of the longest sequence and its length. In (most?) C-like languages you can't easily do that, so you have to return n, and then you need a duplicated call to sequence_Length (line 13) While looking at this myself I was tempted to define a class or struct with both n and its corresponding sequence length just so I could return that but it did seem overkill. If I were to become worried about the efficiency issue of duplicated calls to sequence_Length I would probably prefer to use a Map to cache known n,sequenceLength pairs and thus eliminate re-calculations.
Swift allows you to return an arbitrary tuple from a method, which seems to me to be the cleanest way to code this. (You may be getting a suspicion that Swift as is my favourite language, successfully incorporating the lessons of Java, C* etc , and you would be right.)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can call it a guard or you can call it a base case, but there's no reason to have a guard AND a base case. If you find yourself needing both, you probably have a design flaw.

I respectfully disagree.
A guard protects the following code from incorrect or invalid values
A recursion base case is the case where recursion stops
They are two different things with different uses, and shouldn't be confused. eg

int next(int n) {
    if (n<1) raise error "algorith is undefined for n<1"  // guard
    if (n = 1) return 1;  // base case
    ...

I don't know about C++, but Java uses assert for guards (can be turned on or off at runtime for improved error checking vs performance), and Swift has explicit guard statements/

Personally I'm huge fan of guards to document and enforce a method's pre-conditions

AssertNull commented: Good food for thought. +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Cast your mind back a day or so when you were making great progress by starting with a short pseudo-code text description of the process and some pencil and paper simulation to check it out. You seem to have forgotten about that and are hacking code that frankly makes no sense.
Please do not write a single line more code until you have a working paper simulation.

AssertNull commented: Paper and pencil rarely fails. +7
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I Googled "SUSE server safe mode" and found a load of info that looked relevant to me.