zeroliken 79 Nearly a Posting Virtuoso

you could try reading the text then put the inputs in a 2D array then choose from there

Is there a way to have each question followed by a list of four possible answers all in a text file that can be added to at any time and pull them from that instead of programing them in one by one.

is the answers right next to the questions? meaning theyr'e in one line
you could try getting the whole line using fgets()then tokenize with space as the delimeter then save them in a 2D array

zeroliken 79 Nearly a Posting Virtuoso
zeroliken 79 Nearly a Posting Virtuoso

i cannot get it..can u code it??change it? sorry for being noob =)

I already posted the code for you, all you need to do is manipulate/integrate your program with it

I can't do your homework for you

zeroliken 79 Nearly a Posting Virtuoso

what is the purpose of &enter?

check the commented line at the if condition
also try the code to see it for yourself

zeroliken 79 Nearly a Posting Virtuoso

since number is an integer and not a character datatype using isdigit and isalpha wouldn't be possible
To meet your needs the only workaround I can think of is checking the return value of scanf, it returns 1 when a non-digit number is entered

int number;
char enter;

printf("\nEnter number: ");
if(scanf("%d%c", &number, &enter) == 1 || enter != '\n'){ // enter is used to catch the enter key when pressed
    printf("you did not enter a number");   
}
else{
    printf("valid integer followed by enter key\n");
}

though you can't use it in a loop you might as well just ask again for an input when the if condition is met

zeroliken 79 Nearly a Posting Virtuoso

at your last code, it would always pass that loop if you always initialize variable found back to 1 after the loop

zeroliken 79 Nearly a Posting Virtuoso

is this a duplicate thread with the one I posted at
http://www.daniweb.com/software-development/c/threads/418149/1783115#post1783115?
Your asking the same question

zeroliken 79 Nearly a Posting Virtuoso

next time please put the code between

tags to preserve indentation and and put in number lines to make it a lot easier to read

Now for the code, it doesn't pass the loop with the isalpha conditional because the value of found is not equal to 1 try to make the code less complicated,
just put the isdigit statement at the while condition

zeroliken 79 Nearly a Posting Virtuoso

did you try it with every variable present there?

zeroliken 79 Nearly a Posting Virtuoso

My guess is, it is most probably the way it reads the file
print out those variable's value to see if it does take a character so you can see when and how it happens

zeroliken 79 Nearly a Posting Virtuoso

I mean when I run the program with my input file of test values.
It's supposed to display numbers. some do, but the b statements display nan..

try do debug it check the values (print them out so you can see) of the variables used when it passes the b conditional to see which causes the problem

zeroliken 79 Nearly a Posting Virtuoso

It's just coming up as nan when I use it in this program

weird it always prints out a numeric value in my end?...
what's the value of term that you input?

zeroliken 79 Nearly a Posting Virtuoso

your missing a bracket for the main method, also don't create a method inside main

zeroliken 79 Nearly a Posting Virtuoso

My b statements are coming up as -nan.

what do you mean by this? what does it print out.
I tried to run the code and it worked fine on my end

zeroliken 79 Nearly a Posting Virtuoso

Try it like this:

if (series == 'A' || series == 'a')

and do the same with the conditionals of b and c

zeroliken 79 Nearly a Posting Virtuoso

for example i can only enter DIGIT

using if else statements?

zeroliken 79 Nearly a Posting Virtuoso

instead of removing it replace 0 with the variable you want to return

zeroliken 79 Nearly a Posting Virtuoso

there shouldn't be a semicolon at the end of PersonalInformation()

zeroliken 79 Nearly a Posting Virtuoso

Just thought up on an alternative(better in my opinion) solution in checking if a letter input exists.
Loop the string index and compare each character using charAt() method then change the index of the secret word with the letter input, you could use the StringBuilder class setCharAt() method to change the specified index with the letter

If your not familiar on using the StringBuilder class you can check an example in the oracle docs:
http://docs.oracle.com/javase/tutorial/java/data/buffers.html

zeroliken 79 Nearly a Posting Virtuoso

well, you have two Strings:
1. your original word
2. a String the same length as your original one filled with *'s.

you print the second one. whenever you guess a char, you verify with the original String if the char is in there, and if so, check the indexes of where, and at that same index, you change the char in your *'s char to that char.

you beat me to it... :cool:

anyway to add up to that you could do these:

to create the string of asterisk you may use a loop then concatenate an asterisk to the variable and iterate until the the end of the string length

when comparing the *'s string you could use a String method indexOf()(to get the index position of the letter) with the guess word then replace the * with the same index with the guessed letter

zeroliken 79 Nearly a Posting Virtuoso

And like the user is supposed to draw them?

See the Graphics 2D class...
then check this
http://docs.oracle.com/javase/tutorial/2d/advanced/user.html
and maybe this for the overview
http://docs.oracle.com/javase/1.3/docs/guide/2d/spec/j2d-intro.fm.html#62980

zeroliken 79 Nearly a Posting Virtuoso

Could you post your code and post your question in a detail manner
Anyway here's my suggestion according to your i/o,
just loop through the array and make a conditional if a value is already given

zeroliken 79 Nearly a Posting Virtuoso

But my output is just JFrame(Even color did not get changed)

make a frame instance and add components to it
Something like this:

JFrame frame = new JFrame("FrameDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//3. Create components and put them in the frame.
//...create emptyLabel...
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

Here's the link where I got this and will probably answer your next questions
http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html

zeroliken 79 Nearly a Posting Virtuoso

it's result is correct but it return the value 0

that's because of the return 0 statement at the end of the function,
return the variable you need instead

zeroliken 79 Nearly a Posting Virtuoso

>>int min = total [0];

there's not gonna be a value less than 0
why don't you set min as the first value of the array after the array is filled

zeroliken 79 Nearly a Posting Virtuoso

Your not making use of the PersonalInformation class
To get you started create 3 new instances of this class
I suggest read this
http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html
and the rest of the docs
http://docs.oracle.com/javase/tutorial/java/javaOO/index.html

zeroliken 79 Nearly a Posting Virtuoso

the random() method from the Math class returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
try using one of the the Random class methods instead
Here's an example:
http://www.javapractices.com/topic/TopicAction.do?Id=62

EDIT: Just noticed that you solved it on your own, congrats :)

Valiantangel commented: Hey thats a good link.I will remember but for now i thik math.random() will do. +1
zeroliken 79 Nearly a Posting Virtuoso

how about returning books using CHAR not int it is poissible?

I don't see any books... variable in the code
And if you meant the similar variable, which function are you talking about?

zeroliken 79 Nearly a Posting Virtuoso

you declared the function's data type as void in the function prototype yet you declared it as a char

zeroliken 79 Nearly a Posting Virtuoso

Why leave?

zeroliken 79 Nearly a Posting Virtuoso

sum of 10 first terms series : -1 +2/3 -3/5 +4/7 -5/9 ...

you need to discuss how those terms will be computed in a detailed manner

So for now this is my interpretation of your problem for a possible solution
make a loop that will increments a integer variable by 1 and another variable that increments by the value of the first variable then do the operations you need
and finally convert the final result's to either a negative or positive value for every loop

zeroliken 79 Nearly a Posting Virtuoso

save the value to a another(new) variable then use it a the formula

EDIT: I'm glad that your solving it on your own then

zeroliken 79 Nearly a Posting Virtuoso

What does this

hwo to write total of 10 first setences (C languege)

have to do with this...

-1,+2/3,-3/5,+4/7,-5/9,...

your not gonna get much help if you can't post in english clearly :-/

zeroliken 79 Nearly a Posting Virtuoso

There's already a lot of links in the Starting "C"
Did you finish checking them all already?

zeroliken 79 Nearly a Posting Virtuoso

how can I display the whole equation to make it easier for the user to follow through? instead of just showing the final result?

you could display the process by printing out a similar statement to the formula in the loop
or
you can assign the values used in the loop to variables that will be used in displaying the equation in the end

zeroliken 79 Nearly a Posting Virtuoso

Here's a similar thread that should answer all of your questions present and future
http://www.daniweb.com/community-center/daniweb-community-feedback/threads/121348

zeroliken 79 Nearly a Posting Virtuoso

You can mark this thread as solved then if you have no more questions or problems

zeroliken 79 Nearly a Posting Virtuoso

What have you coded so far?
Will this be using a gui or is it only console presentation of the values?

zeroliken 79 Nearly a Posting Virtuoso

I have added an ActionListener but i want each button to have there own Action.

make a conditional for every array index to execute a specific action

Also what i wanted is to hide the contents in the button.

what contents would you want to hide?

zeroliken 79 Nearly a Posting Virtuoso

Try to iterate over the value of n in the second loop instead of i
then use an if else statement
if the value of j is less than or equal to i print only the value of j
else print a space(" ")

zeroliken 79 Nearly a Posting Virtuoso

use the NOT(!) operator at the loop condition

zeroliken 79 Nearly a Posting Virtuoso

don't initialize variables in a loop

zeroliken 79 Nearly a Posting Virtuoso

did your reply come before the original post???
so, the Morpheus was right. we've found the Chosen One

Weird I thought it was something on my end that's caused my reply to be viewed before the question so I ignored it...

@zeroliken do you know to whos post you been relying before someone split this? If you can give me link I would be able to merge it back

yes I'm replying to frivolous' post

zeroliken 79 Nearly a Posting Virtuoso

make that a do while loop, it expected that the while loop is a part do loop

zeroliken 79 Nearly a Posting Virtuoso

my guess it works pretty much like an AI in a video game

zeroliken 79 Nearly a Posting Virtuoso

make a program that reads the metadata of the selected mp3 file
Here's a link that might help;
http://stackoverflow.com/questions/1645803/how-to-read-mp3-file-tags

zeroliken 79 Nearly a Posting Virtuoso
}while(scanf(" %d ", &length)<200 || scanf(" %d ",&length)>4000);

that should be length<200 || length>4000

im trying to add a input validator

the simplest thing I can think of are using if-else statements

zeroliken 79 Nearly a Posting Virtuoso

Ok then, now could you please answer thines01's question so we can help you further

zeroliken 79 Nearly a Posting Virtuoso

Fix those ending brackets with the loops(starting from the do(while...))
and next time properly indent your code and put it in between

tags so we can check the code properly

zeroliken 79 Nearly a Posting Virtuoso

Could you wrap the code between

tags it's hard to read the code without proper indentation