here is the code and below is the error report i hpoe it helps
ArrayList<Worke r> badiri = new ArrayList<Worke r>(); //create a collection of the workers
double sum = 0.0;
while(inFile.ha sNext())
{
for(Worker worka : badiri){ //fills up the collection with worker objects
badiri.add(new Worker(workerNa me,salaryRate)) ;
...
User Profile
Collapse
-
i have imported the java.util.*; class and it seems like no effect is shown the erro is still there.Leave a comment:
-
Thanks a lot man,the get() method worked but i still get an error on sorting the ArrayList.
i used the method call of
Collections.sor t(variablename) ;
it doesn't seem to recognize the function.Leave a comment:
-
Indexing an ArrayList
Hi guys how does one index an object with a collection in an ArrayList,the code i used reports an error."expected is an array and found is an array list" and the possible loss of precision error.this is the code
while(inFile.ha sNext())
{
for(Worker worka : badiri){ //fills up the collection with worker objects
badiri.add(new Worker(workerNa me,salaryRate)) ;
} ... -
just so happens i did methods/functions which compute factorial,permu tation and combinations of numbers using recursion.i hope they help you since your problem is inline with them.
here they are:
<Code removed by MODERATOR. Please read our posting guidelines forr our policy on simply posting answers.>
well good luck,i will try and figure out how to help you print the permutations.Leave a comment:
-
alternatively you could use a scanner object to read from the file and use the function of parseInt to convert from string to integer and use the value for calculations.
i.e
Scanner inFile = new Scanner(new FileReader("fil ename"));
String x = inFile.next();
int x2 = Integer.parseIn t(x);
then int sqr = Math.pow(x2,2); //this is just an example of a calculation you can do after...Leave a comment:
-
yeh you are write a loop can be used,if you know anithing about binary search or linear search try either of them and i reccomend binary search coz its effective and fast.Leave a comment:
-
public int powerOfTwo(int number)
{
int base = 2;
for(int i=0;i< Math.pow(base,I nteger.MAX_VALU E);i++)
{
int powerOf2 = Math.pow(base,i );
}
}
my apologies for breaking the rules,it won't happen again.as you can see i did attempt but i can only come up with a function which i'm not sure it will give me the powers of two.
I understand x is an arbitrary...Leave a comment:
-
Powers of two
hey guys thanks for the vowel help it worked
i got one other question here.
here is the method/function signature
public int powerOfTwo(int number)
the function should return a number such that number - x is a power of two if number is already a power of two it should return 0. -
Thanks man i will try and see the results, i think i get exactly what you mean.keep it real...Leave a comment:
-
sorry for not giving you guys enough info,i'm trying to write a method/function so i don't know if one can write a method in another method,is there any class api that has the function of isVowel that chaarmann described may be it will be beter to call the method. thanks for the idea thoughLeave a comment:
-
integer pair search
guys i'm to write an application program that gets a filename and number form the command line and print all possible pairs of numbers such that a<b< number and (a^2 +b^2 +1)/ab is an integer
e.g number = 1000
filename = integers.txt
output is
(1,2)
(2,5)
(5,13)
(13,34)
(34,89)
... -
vowels in a string
Hi
i need help with writing a method that takes in a string of characters and counts the syllables in the string.
the method should not count chacter 'e' if its the last character in the string and by definition a syllable is vowel or a pair of adjacent vowels(a,e,o,i, u),the adjacent vowels count as one.
so my problem is identifying that the two adjacent characters are vowels.how can i tackle this?
thank... -
yes there is,but you need to understand that after creating the random number generator object you should use its methods to get a random nuber and store it in a variable/identifier then print the variable.
what you did is try to print the object so since random is an object it holds the address referencing the object so @9304b1 is the address of the object
fing the random class API and you will get the methods,good...Leave a comment:
No activity results to display
Show More
Leave a comment: