~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello there, welcome to Daniweb. :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't have an ad blocker, because they block a site I have to use.

It is really a good piece of software -- provided you know how to configure them.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Down with hypocrisy.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Which thread is the Java one from anyway?

Here it is. I am glad atleast some people were able to spot the difference. ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess my desire for having large font for code is getting over me... *sigh*

Nevermind, thread solved, before everyone out there starts proving I am going senile... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, the C++ is larger than the Java one, and even looks better. I wonder if it was a subtle bug I discovered.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It was just a pointer in the right direction. If the above question is really a homework and the solution is submitted as it is, the OP would have a good amount of explaining to do.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The .h form of header inclusion is still there for backward compatibility and there are many reason you shouldn't use them. This is what I got :

Although the <iostream.h> library was deprecated for several years, many C++ users still use it in new code instead of using the newer, standard compliant <iostream> library. What are the differences between the two? First, the .h notation of standard header files was deprecated more than 5 years ago. Using deprecated features in new code is never a good idea. In terms of functionality, <iostream> contains a set of templatized I/O classes which support both narrow and wide characters. By contrast, <iostream.h> classes are confined to char exclusively. Third, the C++ standard specification of iostream's interface was changed in many subtle aspects. Consequently, the interfaces and implementation of <iostream> differ from <iostream.h>. Finally, <iostream> components are declared in namespace std whereas <iostream.h> components are declared in the global scope. Because of these substantial differences, you cannot mix the two libraries in one program. As a rule, use <iostream> in new code and stick to <iostream.h> in legacy code that is incompatible with the new <iostream> library.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

*sigh* Nevermind. I wish someone else would realize the difference... :-(

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

See the font size in both the cases...The C++ one is one point large than the Java one.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Create a project, open a new file in that project, write your program, press the compile and run button somewhere at the top and you are good to go. That's it !

Which step are you specifically stuck at?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you will notice, code tags behave differently in Java and C++ forums. Why can't we have a consistent formatting across forums? Personally I like the C++ one...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem is not as simple as it looks to be on the surface. Too many things to be taken care of -- handling duplicates, sorting the ratings, associating the ratings with the names. You would have to come up with a better implementation than string arrays. Here is my humble stab at it...

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.TreeMap;

class CompareMappings implements Comparator
{
    public int compare(Object arg0, Object arg1)
    {
        Mappings m1 = (Mappings)arg0;
        Mappings m2 = (Mappings)arg1;            
        return(m1.getSmartness() - m2.getSmartness());
    }  
}

class Mappings
{
    private String name;
    private int smartness;
    
    Mappings(String rawStr)
    {
        rawStr = rawStr.trim();
        int index = rawStr.lastIndexOf(' ');
        setName(rawStr.substring(0, index + 1));
        setSmartness(rawStr.substring(index + 1));
    }
    
    public String getName()
    {
        return name;
    }
    
    public int getSmartness()
    {
        return smartness;
    }
    
    void setName(String name)
    {
        this.name = name;
    }
    
    void setSmartness(String smartness)
    {
        try
        {
            this.smartness = Integer.parseInt(smartness);
        }
        catch(Exception e)
        {
            System.out.println("AN exception occured while settings smartness...: ");
        }
    }
    
    public String toString()
    {
        return("Name: " + name + "  Rating: " + smartness);
    }
    
    public boolean equals(Object arg0)
    {
        Mappings m = (Mappings)arg0;
        return name.equalsIgnoreCase(m.name);
    }
}

public class Temp
{
    public Object[] populateFromFile(String path)
    {
        TreeMap map = new TreeMap();  //use TreeMap to avoid duplicates
        try
        {
            String temp = null;
            BufferedReader br = new BufferedReader(new FileReader(path));
            while((temp = br.readLine()) != null)
            {
                Mappings m = new Mappings(temp);
                map.put(m.getName(), m);
            }
        }
        catch(FileNotFoundException e)
        {
            System.out.println("File not found....");
        }
        catch(IOException e)
        { …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
String str = "as as as as";
int count = 0;
int limit = str.length();
for(int i = 0; i < limit; ++i)
{
    if(Character.isWhitespace(str.charAt(i))
    {
         ++count;
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Let love in - Goo Goo Dolls

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

to look at

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't think this is the one.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

green card - wild card

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

smite

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But still I am pretty optimistic about the way things are turning around. Think of it this way -- a few years back, things like WYSIWYG editors would have been though of as nearly impossible.

After all, who could imagine a text editor like thing embedded inside your browser window, unless you use Active X plugins. Look at Servlets, JSP's and EJB's. Brining the power of a programming langauge like Java to the internet, was the best thing. Who would have thought of spawning threads to service client requests as compared to a seperate process(as used by CGI)?

Like I said before, things are changing and what the future beholds for us can't be determined -- the imagination is the limit.

Re: Re: PS - Good to know that... :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The rainmaker - Iron Maiden

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I think you misunderstood, the thing which I wanted to quote was "unless we drastically change our web programming technologies". The point I was trying to put across is that considering the recent advances in web development and research, a drastic change isn't a distant dream.

PS: I hope you are happy with the kind of recent topics being discussed in the Geek's Lounge or do you want it to get more tech gory... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I never said that web apps would someday replace desktop apps. Each of them has a different place in fulfilling our day to day business requirement. And why would someone use a web app to edit local files?

Want to edit an uploded file, use AJAX based web application and you are good to go. On the other hand, modifying remote or uploaded files using desktop apps would have the same problems like ones you mentioned.

> A web service can't exactly replicate a local application unless we drastically change our web programming technologies.

There you go, you have the answer right with you... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get a chainmail.

I put in a scythe.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

sick old man

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Important warriors without Kermit's sword quit improving their writing skills while attempting to amaze miss Piggy

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

talking and thinking

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Deadlines has got nothing to do with the death of the lines of planar geometry.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Though I haven't as such tested it, but I think this is what you are looking for. If not, then there always are better libraries/languages out there... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Seemingly pleasant invocations ruin inner thinking.

arjunsasidharan commented: thanks for the rep. :-) i was just asking for a new game, we already have to many word games dont we? +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

[tex]1 / 2 = 0.5[/tex]

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

aliens - green

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

mitten

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Nothing, he was just being his usual self... ;-)

Anyways, go to this site and read the hint files which come along with the code to get an understanding of whats going -- though if you are a beginner to intermediate programmer, it would be difficult for you make any sense.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You have to realize that floating point numbers are nothing but normal 32/64 bit datatypes with special interpretation of the bit pattern. If you are really interested, read this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use a third party library like this or use a language which has inbuilt capabilites of handling such arithmetic like Python.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> P.S. I'm not a mod-wannabe

;)

Actually, I've been wondering if it would be possible for mods to split off-topic parts out of threads? They'd have to use some discretion about when it's appropriate and when it's not, but it would help to keep threads a lot more on-topic.

IN case you don't know, this forum has no specific mods and its under the jurisdiction of the super mods and admins. So unless some real flame war is afoot, the off topicness is generally ignored. One thing would be to report bad post, but that as such is a moot point since the off topic post wouldn't be breaking any rules. Hence the given condition.... :-)

Ah well, it's pretty normal for threads to go off-topic and launch sub-debates, I've never found a forum that doesn't do that.

True, but the off-topic topic differs from forum to forum. In some forums, even the off topic posts are pretty informative. In those cases, off topic actually means 'something good about another topic'.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> It's can't really replace a desktop application, but you can come decently close in some cases

Wait for a few more years, you would need ot change that statement. Everything looks impossible till its realized... :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Make the function val count return a vector of integers by making v_found as a vector of integers (vector<int>). Alternatly you can pass the vector reference to the function, and make the function modify the original vector. Print the returned vector or the modified vector in the main function. Something like:

size_t size = v_found.size();
for(size_t i = 0; i < size; ++i)
{
    cout << v_found[i] << '\n';
}


This
would be a good tutorial for you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe this and this would shed some light on it...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sheesh, now I know why web/app developers are all over AJAX. With almost everyone having MBits of connection, web apps that behave like real apps are not far away... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You would be required to have an array of the size the same as the range of numbers to be generated. For eg. as in your case, the range is 5, hence create an array of 5 elements, and for each random number generated, do something like:

int frequencyArray [RANGE] = { 0 };
random_integer = int(6 * rand()/(RAND_MAX+1.0));

// asssuming that the generated number is between 1 and 5.
++frequencyArray [randomNumber - 1];

BTW, why the need to add zero to your random number equation, which I think would also generate 0 which you don't need.

Consider doing:

srand ( static_cast<unsigned int> ( time ( 0 ) ) );
random_integer = 1 + int(5 * rand()/(RAND_MAX+1.0));
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get a retro browser.

I put in some tyres.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

blood - red

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

the light of

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

beaker

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

to say anything

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Wrong always beats right.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

gut - gore