scudzilla 32 Junior Poster

Could you post the code?

scudzilla 32 Junior Poster

At lines 8 and 10, use %lf (small L) instead of %f.

OR, line 6, change double to float.

scudzilla 32 Junior Poster

How about using substring?

Johannady2 commented: yeah.. I tried substring and length.. it works now :D +0
scudzilla 32 Junior Poster

at line 35:

System.out.println("" + firstletter1 + firstletter2 + firstletter3 + firstletter4 + firstletter5);

Also note that because of lines 23 to 27 of your code, all strings str1 to str5 will have the same value which is equal to the last string you input. Move those lines outside of the for loop and enter the index manually. Or you can make str a string array as well. It's your choice.

Johannady2 commented: Now... i'm trying to convert the first letters to uppercase. can you help me. http://www.daniweb.com/software-development/java/threads/422406/help-touppercase-first-lettters-using-for-loop +0
scudzilla 32 Junior Poster

What do you mean by hard reset? Restore the laptop to factory settings, or removing all power and holding the power button for 60 seconds?

scudzilla 32 Junior Poster

Any other info you see in the BSOD?

scudzilla 32 Junior Poster

It is possible. Have you already made the code to sort array1?

scudzilla 32 Junior Poster

Should be for(int i=list.size()-1;i>=0;i--)

scudzilla 32 Junior Poster

Btw, at line 29 of your code, it should be h[i]=(n[i+1]-n[i])

scudzilla 32 Junior Poster

Isn't it because you used mo[j-1] instead of mo[j]?

scudzilla 32 Junior Poster

Oh, now I know why you're getting out of ranges and nonetype elements. You confused the element number with the length. Suppose you create a list x with length 5. Wouldn't the contents of x be (0 to 4)? Or to put it another way, if you create a list x with elements (0 to 5), wouldn't the length be 6? Meaning, for any list x with elements (0 to n), len(x) = n+1. Let's go over the steps in the wikipedia page (note in the following statements, I renamed your list n to list x to avoid confusion with the element n):

Step 1:
a)Create array a with size n+1 (n being the index), or in other words, with size len(x). But you defined a with size len(x)+1

Step 2: arrays b and d with size n, or len(x)-1. But you defined them with size len(x)

Step 3: array h with size n, or len(x)-1 - same as step 2

Step 4: array g with size n - same as step 2

Step 5: arrays c, lo, mo, zo with size n+1 or len(x) - same as step 1

Step 6: you've done it ok

Step 7: for i = 1,...,n-1 which translates to for i in range(1,len(x)-2) but you wrote for i in range(1,len(x)-1)

Step 8: lo(n), zo(n) and c(n) or lo(len(x)-1), zo(len(x)-1) and c(len(x)-1) respectively, but you wrote lines 50 to 52 instead

Step 9: for j = n-1, n-2,...,0 which translates to for j in …

scudzilla 32 Junior Poster

Strange, I'm not encountering any error, except the unindent issues at lines 63 to 66.

scudzilla 32 Junior Poster

On second thought, it's not definite that I could recreate those errors in my own code. Is it possible for you to post the rest of the code?

scudzilla 32 Junior Poster

Hmm lemme compile the code. Unfortunately I'll have to recreate the rest of the code so it'll take some time.

scudzilla 32 Junior Poster

Do arrays m and n have fixed sizes? If so, what are the sizes? If not, is it possible for len(m) to be greater than or equal to len(n) - 2?

scudzilla 32 Junior Poster

Your array of n has a maximum index of len(n) - 1. Your counter i ranges from 0 to len(n) - 1. So far so good. However, at line 14, you're trying to access the (i+1)th element of array n. What happens once i = len(n)-1? i would be equal to len(n), which exceeds the maximum available index of len(n)-1, hence the index out of range.

@pyTony I think m and n are already defined, just not included in the "part" of the code s/he posted here. I may be wrong though.

scudzilla 32 Junior Poster

Yes, that's correct.

scudzilla 32 Junior Poster

The keyboard's Enter key gives a combination of two characters: carriage return (\r, ascii=13) and newline (\n, ascii=10). Since you're reading only one character, the character that is read is the first one which is carriage return. Look them up for their functions :) (Forgot to mention the combination is for Windows systems. Other systems may differ)

scudzilla 32 Junior Poster

Try changing line 51 with if((c = getch())==13), 13 being the ascii of the character of carriage return.

scudzilla 32 Junior Poster

That happens because you are trying to access the elements of an empty vector. You could do two things: first would be to resize the vector after you input the number of students (syntax: Grades.resize(num); or, initialize the vector entirely after the number of students is entered (aka move line 9 to line 15, and include num as the size)

scudzilla 32 Junior Poster
  1. You are storing the number of students into i, which gets reassigned a new value. Store the number of students into another integer variable (num, perhaps?).
  2. At lines 15 and 23, you use i for the counter, starts at 0, but your condition is that it will end once i is greater than or equal to 0 which means your for loops do nothing at all. You are supposed to use another integer variable (num) at the condition. for(i = 0; i < num; i++);
scudzilla 32 Junior Poster

The character array pass cannot find a null value after the last password character. It will continue to read beyond the last character until it finds a null value (on or before the 30th byte after the first character). That is why the pass read at Line 93 may include additional garbage characters, hence the inequality with the password read in the file. To rectify it, add a pass[i] = 0; between lines 88 and 89 to let the program know where the true password ends.

scudzilla 32 Junior Poster

Here it is. I hadn't thought using scientific notation for the really large numbers, nice idea. I dunno how to balance accuracy vs practicality. This will continue to print every single number of every single stn from 0 to input. If I were to use scientific notation, I'll probably leave a hundred digits before the 10^x. Probably even more >.< Anyway, it takes prolly 4 secs to get the first 1000, and each stn after that takes more time to print because the number of digits keep increasing. Takes 6 mins for 10000 in my laptop.

        import java.util.*;
        import java.math.*;

        public class FunLoops {
            Scanner in;
            BigInteger [] arr;
            BigInteger two = new BigInteger("2");
            BigInteger thirtyfour = new BigInteger("34");
            int input;

            public FunLoops() {
                in = new Scanner(System.in);
                run();
            }
            public void run(){
                System.out.println("How many square triangular numbers do you want printed?");
                input = in.nextInt();
                arr = new BigInteger[input];
                for(int i=0; i < input; i++){
                    rec(i);
                    System.out.println("Square Triangular Number #" + (i) + ": " + arr[i]);
                }
            }
            public void rec(Integer i){
                long total;
                if(i == 0){
                    arr[0] = BigInteger.valueOf(0);
                }else if(i == 1){
                    arr[1] = BigInteger.valueOf(1);
                }else{
                    arr[i] = thirtyfour.multiply(arr[i-1]).subtract(arr[i-2]).add(two);
                }
            }
        }
scudzilla 32 Junior Poster

Ok. I tried the code, typed in 50 as input and got the first 50 in an instant. Even with 100 as input, it gives out everything instantaneously.

scudzilla 32 Junior Poster

Create a dynamic bigint array, initialize it with size input, and modify the rec function. I have actually created the code, just have to test it. I'll post it if it works. By the way, did you really get the first 30 stns instantly? I got the first 10 instantly, had to wait a couple of seconds for 11th, a little longer for 12th and I didn't have the patience to wait for 13th.

joankim commented: thanks for doing this with me :) +1
scudzilla 32 Junior Poster

Ok. First, since you used the syntax thines01 posted, there's no more need for an arr array. However, you could use arr as a string. So, you can remove those [] at line 9 now. Next, you're not supposed to replace string.join with arr.join. You are supposed to assign string.join to arr. arr = string.Join(",",files.ToArray());

scudzilla 32 Junior Poster

Then follow my previous post (both lines 43 and 67), but disregard parts with the ",", and the newline/return combo.

scudzilla 32 Junior Poster

Are you supposed to send the list itself? Or merely a string representation of the list? If it's the latter, you should change a few things.

At line 43: You created a string, but you did not assign it to a string variable.
Additionally, the "," part decides how the list should like like. At present, each filename would be separated by a comma:

filename1,filename2,filename3,....

If you wanted to make it more like a list like:

filename1
filename2
filename3
...

then replace that comma with a newline/carriage return combo.

At line 67: simply replace files with the string variable you are supposed to use at line 43.

scudzilla 32 Junior Poster

To reprhase thines01's post:
convert your list of strings (aka files) into a string array (let's say, arr) using .ToArray(), combine all elements of this new array into a single string using string.Join, and assign that to a new string variable. thines01's post has the syntax.

scudzilla 32 Junior Poster

Probably because at line 43, you used int(x) instead of just x? x at that point far exceeds the max value for an integer.
Also, at the example you posted above, total/x are long and incrementer is float.

scudzilla 32 Junior Poster

These are just guesses.
I've tried only two types for incrementer (float and long), and kept total as long. The thing is, when incrementer was float which is 4 bytes, it probably converts total from long (8 bytes) into float, add incrementer to it, then convert back to long. Maybe the conversion causes loss of the upper bits and therefore gives out an incorrect value. It probably goes the same with int, which is also 4 bytes. (I've never tried int in your program). That is probably why these two types give the wrong output despite total not reaching its max value. With incrementer as long or double, which is another type with 8 bytes, total will not be converted down, and thus, no loss of accuracy. However, they may reach maximum value and give out the wrong output. (For long, you and I both have experienced having negative output, which means that, being signed, it exceeded the max positive value) (For double, I have not tried it but you said it kept printing out the max value)

scudzilla 32 Junior Poster

Have you tried using bigint?

scudzilla 32 Junior Poster

No, all the if statements are individual. Nothing nested. Something like:

if(a<=b){
    a = a + b;
    b = a - b; //switches a with b
    a = a - b;
}
if(a<=c){
    a = a + c;
    c = a - c; //switches a with c
    a = a - c;
}

and so on

scudzilla 32 Junior Poster

For 5 numbers, it can be done. All you have to do is place the lowest (or highest) number into a, using four if statements (compare a with b,c,d and e, then switching each time a is less (or greater) than one of those). Follow it up with comparing b to c,d and e (three if statements, making it seven total). Lastly, compare c with d and e (two statements, making it nine statements total). Since you're looking for the median in a group of five numbers, you will need the third number, which is c. You don't have to compare d and e (and even if you do, it takes just an additional one if statement, making a total of 10).

scudzilla 32 Junior Poster

Have you tried ommitting the IN? Or if Score is a string, then make it operator & "' & Score & "'"

scudzilla 32 Junior Poster

Hmmm provided the value in the combobox corresponds to a valid field in the database, no matter the value of s, it should not generate an error (which means you don't need to check the value of s). If however, the combobox doesn't, then it becomes an error. I assume your combobox style is a dropdown combo, such that you could enter any value in it, or that at runtime its original value is -1 and you search before changing it.

Things you could do: a) make it a dropdown list style, and at Form_Load, add combo1.listindex = 0; or b) like BitBlt said, write a code that checks whether the value selected in the combobox corresponds to a field in the database. You can do this by using an if-and-then statement.

scudzilla 32 Junior Poster

I'm gonna give a college student's pov

1. still studying computer engineering

2. lots of mathematics classes (both theory and applications)... exams almost everyday (my scores range from F to A with A being the higher probability)

3. training eh? i'm still in college and i've got to adimit that only half of my subjects are useful for future occupations

4. easiest part.. exams.. hardest part.. exams as well.. I can't really explain much

scudzilla 32 Junior Poster

3gz processor and 1gb ram.. I'd say those will yield good gaming results for the games of today. If you want to upgrade for gaming, I'd suggest upgrade the video card.

scudzilla 32 Junior Poster

Could you specify which second = txtdisplay.text causes the error? And what type of error it is?

scudzilla 32 Junior Poster

Ok, so you have made the equals into a label as well and it has an index of 4? Let's look at your lblsign_click Sub. It assigns a value to first, then deletes the text in txtdisplay, then assigns the sign which could be "=" and this will make an error later on. Next, txtdisplay.text will be equal to the value of second, to which you have not assigned a variable. If you allow me to correct part of the code, I'm going to add 2 new boolean variables called check which will check if one of the variables have already been assigned a value and checktext which will decide when to clear the textbox during continuous arithmetic processes. So the editions are:

Dim check as Boolean
Dim checktext as Boolean
 
Private Sub lblnumber_Click(Index As Integer)
    If checktext = True Then
        txtdisplay.Text = ""
        checktext = False
    End If
    If txtdisplay.Text = "" Then
    txtdisplay.Text = lblnumber(Index).Caption
    Else
        txtdisplay.Text = txtdisplay.Text & lblnumber(Index).Caption
    End If
End Sub
 
Private Sub lblsign_Click(Index As Integer)
    If check = False Then
        second = txtdisplay.Text
        sign = Trim(lblsign(Index).Caption)
        If Index < 4 Then check = True
    Else
        first = second
        second = txtdisplay.Text
        txtdisplay.Text = ""
        If sign = "-" Then
            txtdisplay.Text = first - second
        ElseIf sign = "+" Then
            txtdisplay.Text = first + second
        ElseIf sign = "*" Then
            txtdisplay.Text = first * second
        ElseIf sign = "/" Then
            txtdisplay.Text = first / second
        End If
        second = txtdisplay.Text
        If Index < …
scudzilla 32 Junior Poster

Whoops! What's gotten into me? My memory must be fading, or maybe I'm just too sleepy right now. Once again, everyone, I'm sorry for double posts. I do hope this will be the last time.

Er, wrong solution. It should be that in the lblsign_Click sub, it must be sign = Trim(lblsign(Index).caption) . Next, as I said before, it should be second = txtDisplay.text and delete the sign = lblsign(Index).caption in the cmdEq_Click sub.

Once again, I'm very sorry.:$

scudzilla 32 Junior Poster

so How do i asssaign the numbers to first and second?
and can you help me with the cmdEq button. it's not working properly.

Like I said in my second post, I didn't see that you have already assigned numbers for your variables and that you reversed the assigning process to second. Now, however, I figured out another problem. If you'd check the captions of your lblsign's, spaces are included, meaning that for the "+" label, the caption is not "+" but " +" and the same for the others. Either you change the captions such that spaces are deleted, or you could change your assignment codes. My best suggestion is that you use Trim$ function to omit any space included. In short, use these:

In the lblsign_Click sub,

first = Trim$(txtDisplay.Text)

In the cmdEq_Click sub,

second = Trim$(txtDisplay.Text)

The other solution is to delete the spaces in the captions of your lblsign's and change the alignment property to 2-Center so that the signs would still appear at the center.

And I repeat!!! The txtDisplay.Text = second should be second = txtDisplay.Text should you use the latter solution.

scudzilla 32 Junior Poster

Sorry for the double post. I didn't see the assigning of the variables the first time. Please look in the sub Eq_Click() , txtdisplay.Text = second must be second = txtdisplay.Text . You reversed the assignment.

scudzilla 32 Junior Poster

You didn't assign the numbers to first and second. And in Private Sub cmdEq_Click() , you can remove the sign = lblsign(Index).caption because it is not necessary and if not removed will alter the results.

scudzilla 32 Junior Poster

Does this help?

Dim TaskID As Long
    TaskID = Shell(pathname\filename.exe, vbNormalFocus)