No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
7 Posted Topics
I have a HashMap with String keys and Integer values. I want to get a string with the String keys in numerical order of their String values. eg. if I have Orange=1 apple=4 pear =2 grapefruit=3 I want the following String apple, pear, grapefruit, orange. I'm not sure how to …
I've tried this and it works public class Anagram1{ private String x; private String y; private char[] xarray; //? private char[] yarray; //? public Anagram1(String phrase1, String phrase2){ x = phrase1; y = phrase2; } public void xlettersort(){ x= x.toLowerCase(); xarray = x.toCharArray(); java.util.Arrays.sort(xarray); } public void ylettersort(){ y= y.toLowerCase(); …
I have a Java HashMap with String keys and Integer values. I need to produce a string which has the keys in the same order as their corresponding values sorted by numerically descending order. What are my options?
Sorry if this has been asked before but I have tried to find a solution elsewhere. I am using the getline function to receive input from the keyboard and save it in a text file. The problem is that it insists on printing a null character (the square box thingy) …
If you put [code] void setcolor(unsigned short color) { HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hcon,color); } [/code] this before the main process you can call the setcolor function before you print to the screen using numbers 0 to 15 as parameters eg [code] setcolor(3); cout << "I'm blue"; [/code] Experiment and …
Your code is some way short of a working solution. I don't think you need a for loop in the main function, probably a loop is needed in the data entry function. It is not clear whether there is a set number of names to be entered or if the …
Supposing I have a class Dog with attributes age and color. I also have a function print(string) which invokes the accessor functions for the dog attributes. Now when the user enters the name of a Dog object at the command line I would like to call the print function to …
The End.
spider_pig