zeroliken 79 Nearly a Posting Virtuoso

the whole program is commented out...
put */ at the line after the author

zeroliken 79 Nearly a Posting Virtuoso

Can't live with them, can't live without them

-What society feels about them and their works

zeroliken 79 Nearly a Posting Virtuoso

What method would I use in order to count the numbers in the output... Like how many 1's and how many 2's etc. etc.

Wouldn't it be much easier if you add 1 to a counter exactly after the generated number

//your number generator code
for (int i = 1; i < 10000; i++) {
                int rand = generator.nextInt(97);
                vect.add(rand);
                vect.add(Math.abs(generator.nextInt()) % 99);

                //use a loop will add number instance to a counter
                for (int j = 1; j < 99; j++) {//iterate 1-99 for the array's index
                    if(vect.get(i)==j)//once found
                        //you add 1 to the array with the same index as j... check stultuske's post 
                }
            }
zeroliken 79 Nearly a Posting Virtuoso

following songokute's post, they're already in an array of strings(for every line that is)
you could use a loop to check

for(int i =0; i < State.length ; i++)
    System.out.println(State[i]);
zeroliken 79 Nearly a Posting Virtuoso

β€œ It's not at all important to get it right the first time. It's vitally important to get it right the last time. ”
- Andrew Hunt and David Thomas

zeroliken 79 Nearly a Posting Virtuoso

simple way to check if a JButton is not Enabled

isEnabled() would return false if the button is not enabled and true if otherwise
Isn't that enough to know that the button is not enabled?

stultuske commented: why go easy if you can go the hard way ... thought this post would solve the thread, but hey :) +12
zeroliken 79 Nearly a Posting Virtuoso

Learn to Love, Love to Learn

DJSAN10 commented: nice +0
zeroliken 79 Nearly a Posting Virtuoso

Why is everybody helping a person who can't even ask a normal question?

There can various reason one can think of but I think its
Just because :)

zeroliken 79 Nearly a Posting Virtuoso

Duplicate post

You should have properly indented the code on the first thread and posted on same thread instead of creating a new one
(which by the way the formatting isn't any better than the first)

myrongainz commented: fuk you -1
dij_0983 commented: @OP don't be rude keep it pleasant +1
zeroliken 79 Nearly a Posting Virtuoso

Thank You very much for your help. I will try to carry on from here. Still, is such an concept all that useless? Got the idea, when one of my colleague (No touch with C++), ran my program and was quiet confused with the matrix. So just wanted to make it user-friendly.

Anyway Thanks again.

Yes it might be fun and user friendly but only for a while... It's not like your gonna use the program or use it as a basis for another program years for now
....then again who knows I could be wrong ;)

Instead you could also show the user the position they're inputting the number like e.g
"Enter number for row 1 column 1:"
To make it a bit more user friendly without going to all the trouble your doing right now

Just a suggestion :)

zeroliken 79 Nearly a Posting Virtuoso

Don't use gets()
-->Article explaining why not
Try to use fgets() instead

PrimePackster commented: Thanks.... +3
zeroliken 79 Nearly a Posting Virtuoso

@OP
Then how can you check if the values of max1, max2 to max3 at the loop is satisfactory and know where the problem in assigning might lay considering that the function is returning garbage values?
You did not even post the values your trying to pass to getTopThree() so its more on guesswork on our side

I'm just trying to help here :(

mKorbel commented: good comment +11
zeroliken 79 Nearly a Posting Virtuoso

it will only loop as long as the necessary conditions are met in the while statement to continue the loop

also the first else if condition cannot happen, you cant have a value less than or equal to 2 and at the same time greater than 5

zeroliken 79 Nearly a Posting Virtuoso

In short...
In your main function you never assigned a value to multiplication but you try to show its value in line 15

printf("Multiplication of the first %d elements of the array is %d\n", n, multiply_array_elements(ar1, n, multiplication));

It won't work since variable multiplication has no value

But, when I run the program, I always get very big and false numbers.

when you pass multiplication to the multiply_array_elements function what do you think is its first value?

zeroliken 79 Nearly a Posting Virtuoso

This is the community Introduction forum

Post your thread in this forum
Windows Vista and Windows 7

zeroliken 79 Nearly a Posting Virtuoso

No, i don't want to make games. It was just easiest thing for noobs.

What applications do you want to make?

Did you check the link I posted It might help you clarify some things between c and c++

Edit: sorry just saw your edit of your previous post

I want to make programs connected with internet.

what kind of program? its purpose? :)

zeroliken 79 Nearly a Posting Virtuoso

Here's a link to a read me thread in the Computer Science forum
Programming FAQ

There's topic there concerning c and c++

(i can make some basic games and programs, like snake game)

For basic console games I suggest c
Though if you want to create complicated games(3d) I suggest c++

zeroliken 79 Nearly a Posting Virtuoso
if(timesshot != 45);
{
//...
}else{ 
     if(timesshot == 45);
     {
     //...
     }
}

try to remove the semicolons in your if statements

Now why make an "if(timesshot == 45)" statement when you already have an else statement (@ the "if(timesshot != 45)" statement) for that very purpose?

zeroliken 79 Nearly a Posting Virtuoso

to change JButton size:
ButtonName.setPreferredSize(new Dimension(buttonWidth, buttonHeight));

zeroliken 79 Nearly a Posting Virtuoso

β€œFor last year's words belong to last year's language and next year's words await another voice.”

-T.S. Eliot

zeroliken 79 Nearly a Posting Virtuoso

Make a String Tokenizer program and set the delimiters to characters other than the alphabets

zeroliken 79 Nearly a Posting Virtuoso

use .equals when comparing Strings instead of ==

though I think it would have been more appropriate if the data type of choice is an int rather than a String

zeroliken 79 Nearly a Posting Virtuoso

would you feel better if you don't use them...
like just use next() in lines 17, 39, 48

puppycrazy commented: thx so much~problem sloved ad! +0
zeroliken 79 Nearly a Posting Virtuoso

try using fscanf when reading a file, you can use google if your not familiar on using fscanf

zeroliken 79 Nearly a Posting Virtuoso

Start small like trying to get if the input is a perfect square before the others

zeroliken 79 Nearly a Posting Virtuoso

Thank you for your useful input :) You are correct, I meant
while(grade.equals("A") || grade.equals("B") || ...

but that gave me an error message, I don't really think || will work for Strings.

huh really... || in a while statement means it will continue to run as long as at least one of the conditions will suffice

I think it should work regardless of the data type

P.S.JamesCherrill Did a better way of showing how the while loop should continue to run
rather than my lazy while(true) :)

zeroliken 79 Nearly a Posting Virtuoso
while(grade.equals("A" + "B" + "C" + "D" + "F")){ //try while(true)
grade = in.next(); //include this in the loop
joankim commented: thank you mate :) +0
zeroliken 79 Nearly a Posting Virtuoso

Since there's no limit in grades I suggest using a while loop instead of a for loop then stop the loop when a non-grade character is input

zeroliken 79 Nearly a Posting Virtuoso

Also don't forget to free the memory after use

for(j=0;j<noe;j++){
              free(p[i]);
        }
	free(p);
dij_0983 commented: Was searching the forum and found this,thanks +1
zeroliken 79 Nearly a Posting Virtuoso

Is it showing a compiler error? post the errors
Is it showing unwanted output? post the output
Do you know how to properly format your code and wrap it it in code tags before you post? If yes then do so

zeroliken 79 Nearly a Posting Virtuoso

We can only help you if you help yourself post your code if you have problems with them

Ancient Dragon commented: Absolutely :) +17
zeroliken 79 Nearly a Posting Virtuoso

If the price is fixed you could have just initialized it already e.g.

private double coffee = 1.00;

Now I don't see a method name for the following.. Is this supposed to print the output

{
System.out.println("Item Name	 Price");
System.out.println("Coffee	 $1.00");
System.out.println("Water	 $2.00");
System.out.println("Milk	 $1.50");
System.out.println("Bagel	 $1.25");
System.out.println("Donut	 $0.75");	
}

Now I could tell you the right way to make your class but learning on your own will be more rewarding so I'll post this link on how java classes are constructed

AAChaoshand commented: will not do the work but will help the person, I like this method as it helps me understand the material. +0
zeroliken 79 Nearly a Posting Virtuoso

There are tons of exercises on the web if you just search right.. try google search

zeroliken 79 Nearly a Posting Virtuoso

you should have used your previous thread instead of creating a new one

zeroliken 79 Nearly a Posting Virtuoso

then why not convert it say 1.5 percent will become .015 then add it or do any operation with it

zeroliken 79 Nearly a Posting Virtuoso

If the output should be a double then why not declare balance and nbalance as a double?
and why not declare left as a double too?

and if you want left to be int then just convert it double then

zeroliken 79 Nearly a Posting Virtuoso

I already showed the right way of printing it out in my first post

System.out.println("There are " + count + " student(s) in the class");
System.out.println("The total of their scores = " + total + "points");

zeroliken 79 Nearly a Posting Virtuoso

for( c=0; c <= b; b++){
println("b = " + b);

Since nothing happens to c it will never be equal to b which is why it loops forever

if(b ==5){
println("loop terminated " + c++);
}

Also since b = 6 it will never be equal to 5

zeroliken 79 Nearly a Posting Virtuoso

printf("%d = %d\n",j,freq[i-2]);

why are you using you using freq[35998]?
I think that integer i your using is supposed to be j.

zeroliken 79 Nearly a Posting Virtuoso

Heres a more relevant example to your structure

struct emp{             //example structure
     char name[20];
  };

 void add(struct emp *employee,int n){
    int i;

        for(i=1;i<=n;i++){
          printf("Enter employee %i",i);	//my example on receiving input
          printf("\nEnter name:");
          scanf("%s",employee[i].name); 
        }
   }
 
  main()
  {
   int num = 5;			//defined number of employees
   struct emp employee[1000];	
   add(employee, num);         
  }
zeroliken 79 Nearly a Posting Virtuoso

We're supposed to have an array that stores every employee that is created, but i dont know how to create/'name' new employee's on the fly.

Does scanf on each index on the array doesn't solve your problem?

So my real question I guess is how do i set up my function call and definition?

Since I don't know what your structure looks like I'll make this example

struct x
   {
      int a;
      int b;
   };

   main()
   {
      struct x z;
	
      z.a = 5;

      printf("The first member is %d \n", z.a);   
   }

could you post your code for more details?

zeroliken 79 Nearly a Posting Virtuoso

Correct me if I'm wrong but shouldn't you use fscanf or fgetc since he needs to read a file?

myk45 commented: Thanks! +6
zeroliken 79 Nearly a Posting Virtuoso

β€œDon't be afraid to make a mistake. But make sure you don't make the same mistake twice.”

-Akio Morita

zeroliken 79 Nearly a Posting Virtuoso

When I compile it the squares that you said that is suppose to be in the top right quadrant appear in the bottom right quadrant

while(b<51)
{
g.setColor(new Color(r.nextInt(COLOR), (0), (0)));
g.fillRect(MIDX+50, MIDY-50, r.nextInt(48)+2, r.nextInt(48)+2);
b++;

the y value coordinate in computers has the opposite value from the regular cartesian coordinate plane meaning the upper side is negative and the lower side is positive

zeroliken 79 Nearly a Posting Virtuoso

Does it really need to be a String function?

Because you can use a simple for loop , if/else statement and a counter to output the consecutive character

Though if (any) String Function is required at all you can use strcmp on each index(a letter) and the index after that(next letter) to know if it is consecutive though it is inefficient.