well AFAIK even if you convert the values to double You can't store them in an int variable
my counter is causing the problem
which variable are you talking about?
well AFAIK even if you convert the values to double You can't store them in an int variable
my counter is causing the problem
which variable are you talking about?
1. You should have posted in the Java Forum for experienced Java users to see this post
2. Why make a duplicate thread about the same problem with your last thread?
3. Are the suggestions in the other thread not helpful?
my last problem seems to be getting my whole program to work with doubles rather than ints,
Initialize the variables as a double then match the arguments at the printf() statments
while my counter remains an int
if your talking about the variable counter then there's not really a need to make it a double
Is it something like the loop doesn't pass the if (card == hand[k]) statement?
I compiled the code a lot of times and though rarely I get results where this event occurs
well I'm not exactly sure how to solve this but just a suggestion maybe you shouldn't use an else statement for assigning the variable to the array cause when the first element is not equals to it the else statement occurs which does this
maybe you could try using a boolean like statement like this
int found = 0;
for (i=0;i<5;i++)
{
j = rand()%52;
card = deck[j];
for (int k=0;k<5;k++)
{
if (card == hand[k])
{
i--;
found=1;
break;
}
}
if (found == 0)
{
hand[i] = card;
suit = card/13;
face = card%13;
printf ("%c of %c \n", faces[face], suits[suit]+3);
}
found = 0;
}
after compiling this a lot of times I haven't received a duplicate output yet
I see... could you post the whole code so I can see everything instead of asking questions
debugging is hard when you can't see the whole program especially when helping someone across the web
Shouldn't the variables be initialized in the main function then passed on to to other functions or use global variables to change the value?
like in your setupDeck() function deck is not initialized
Hmmm... isn't it that the elements of deck have no value?
so whats the use of line 16?
@jbennet
Shouldn't this be moved in the java forum?
@MichaelCJ10
while (counter<total.length)
{
counter++;
...
When you start your while loop you immediately started with an increment to the counter which caused it to use the next element instead of starting with wages[0]
Next
final int TOTAL_LENGTH=11; //declare constant
The array has only 10 elements
How to we know that there is the error of javac
Is it an error with a program or with you using javac itself?
is it possible to create new 1D array from 2D array?
yes
How to create new array from array 2D member?
iterate over the 2d array and save the desired values from the 2d array to the new array
Sorry but this isn't a 24/7 coding service
If you need help then do your part and we'll do ours
May I ask where is the Programme class
if you want to find a particular character and then replace a particular position first you should convert the string to char array then iterate over the character array and change the character you want to
Since the code have been handed down to you we might as well go with it :-/
Anyway did you notice those those commented lines with tells when all three words are the same
Try to modify the code so that it will first check if all the words are equal then if not sort them
psh, come at me bro:
package i.r.teh; import java.util.*; class car { Map<String,String>args =new HashMap<String,String>(); void addargs(String arg, String Arg) {args=new HashMap<String,String>();args.put(arg,Arg);} String gimmeargs(String arg) {args=new HashMap<String,String>();return args.get(arg);} public String toString() {return "I make go do fast";} public static void main(String[] args) {i.r.teh.car c = new i.r.teh.car();c.addargs("make","rawr"); // etc } }
You can thank me for the A later...
ztini, I've noticed that lately you've been giving away codes for the OP without explaining how the code works and your doing the work that they're suppose to do
Please refrain from helping them this way, it's a lot better if the OP learns on how to solve their own problem than just giving them the exact solution right away
We should help by offering suggestions and algorithms, showing their code errors, suggesting program efficiency or an alternative, etc.
Read this: We only give homework help to those who show effort
I'm glad that It's finally solved, congrats ;)
The brackets at line 26 and 27 are not needed
How about the read me threads at the top of the C++ forum
http://www.daniweb.com/software-development/cpp/threads/70096
http://www.daniweb.com/software-development/cpp/threads/67837
You can mark this thread as Solved then :)
if any would recommend some good tutorials would be great
Did you try searching the web about this?
today my teacher told us to use pipe and fork to write a program without teaching us anyway
This might sound rude but if this happened to me I'd petitioned to have a new teacher
A combination of my favorite number and random words that popped on my mind
the for loop for printing the value of sumCount should be outside/after the while loop
first use fgets()
then about the problem
scanf() is leaving a newline character in the stream for fgets()/gets() to read. either change how you're using scanf(), or use a different method of input.
Read this post:
http://www.daniweb.com/software-development/c/threads/412789/1761216#post1761216
Can you post your code?
That sounds like I'd be spoon feeding you so sorry but I'll pass
I really do not understand why I do not get the desired output.
Print the values of odd[count] and even[count] in the while loop and you'd see that eventually they'd get the values of:
odd[count] with {1,2,3,4,5,6,7,8,9} and
even[count] with {2,3,4,5,6,7,8,9,10}
so simple iteration won't work
at the odd numbers it should remain as the value of i
and the same at even numbers i+1
then use
sum[count] = odd[count] + even[count];
then after count+=1; , iterate using i+=2;
that should give the right values for the odd and even numbers at your code
Does not work.
what do you mean by this? is there an error or you can't get the desired output?
could you post those errors or output.
hmm.. well I tried the program and did what I suggested and I got it to work...
Common mistake that everybody makes. :)
Line 21 : use "&" in scanf
the same with line 27, 35 and 44 :)
at the while loop how about you put i++; after count+=1;
where exactly did you put it?
Also I suggest to change your for loop to print the values
something like this
for(int counter = 0;counter <10; counter++){
//print out sum with counter as the index
}
Edit: there's nothing really wrong with the for loop I was just suggesting a better way to view what's going on :)
but nothing is drawn.
the drawing should be done in the paint method, then try to use the values you have in the drawOneCircle method for the coordinates
here's an link for more info about this that might help
http://en.wikibooks.org/wiki/Java_Programming/Graphics/Drawing_shapes
the problem is in your while loop you don't change the value of i
try to iterate i
yes we can help
What have you coded so far?
What part are you having problems with?
the setColor should be in the paint method
It's a practice to always declare variables at the start of the program
Don't initialize the strings s and f inside an if statement
initialize them from the start and remove all the declarations in the if statements
Why can I not use a string created during an if/else statement
my guess is the compiler wouldn't find the symbols used in line 69 at compile time
I suggest you use a reference string for the alphabets
then you need to use a nested loop
one to replace an index with every character from the reference string
and the other loop for every character of the word
What have you coded so far?
After seeing his post above I now agree with caperjack, only thing is now it's not just the signature but the post as well
when i want to enter value the emp_name,basic are skipping
It wouldn't skip if you enter a single character because they have a char datatype... try string
what steps must i under go to solve it.
get the pseudocode or algorithm of the problem?
pass the arrCam array to calculateTotInvent method
Here's a link that might help
http://www.java2s.com/Code/Java/Swing-JFC/AsimpledemonstrationoftextalignmentinJLabels.htm
the terminology and logical or theory side of programming.
As in general programming?
well this is a long and broad topic and in any case being in a computer science or a related course will give more information about this, how about an online course :)
As for me I can't really recall my early days as a student but it's more or less about History of Computer(Software), Concepts involving IT, binary digits and C programming
@ line 161 you forgot the semicolon [TEX](;)[/TEX]
then declare the variables at line 163-166 before using them like in line 158-161
Did you add the image before you added the buttons and labels?
how about you initialize the value of menu to zero @ line 23
int menu = 0;
im sorry,i dont get it, is this what u mean?
At your last code lines 28-43 are unnecessary
Here's a link with a similar topic which might help you
http://www.daniweb.com/software-development/java/threads/187946
could you post your current code so we may see what you did
remove the printf() at line 32 and put it as a default case and don't forget the break if it's not the last case
also menu can only take an int value
Edit: just use a single switch statement and a single loop on it and put the user input at the beginning of the loop
and this line:
printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");
should be the default case
put the user input lines inside the loop otherwise the value of menu will never change