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
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
Try it like this:
if (series == 'A' || series == 'a')
and do the same with the conditionals of b and c
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
>>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
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
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
You can mark this thread as solved then if you have no more questions or problems
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(" ")
use the NOT(!) operator at the loop condition
don't initialize variables in a loop
make that a do while loop, it expected that the while loop is a part do loop
Ok then, now could you please answer thines01's question so we can help you further
Actually it's working the way you code it.
the last iteration will be the final value of sumsq and that will be returned
maybe you could use a loop to pass every index of the array to the function
I see now the problem
for (int i=1; i<=n; i++)
{
cout << "Please enter the value for x " << i << ": ";
cin >> x[n];
cout << "Please enter the value for y " << i << ": ";
cin >> y[n];
}
your accessing the wrong index that should be x and y
array indexes start at 0 and it's always 1 less than the size shown
for example array[9] has elements 0-8
you need to assign every element one by one
try something like this:
//initialize dynamic array
double ** similarities;
int i, j;
similarities = (double **) malloc (5 * sizeof(double*));
//then check if it can't allocate enough memory
for( i = 0; i<5 ; i++){
*(similarities + i) = (double *) malloc (5 * sizeof(double));
//*(similarities + i) can be similarities[i]
}
for (i = 0; i<5; i++){
for (j = 0; j<5; j++){
similarities [i][j] = similarities_b [i][j]; //assign values
//similarities[i][j] can be *(*(similarities + i) + j)
}
}
But,the problem is that i can't go on writing all 360 cases for 360 values of an angle.
what I'm seeking is a solution for shortening the program length by somehow testing the condition in the case...
Is there any way of doing that??
that's where if else conditions shines, is it really required to use only a switch statement?
Next time do please wrap your code between
tags so it will be easier to read the code
It is giving me the correct output but after putting in the "Annual Salary: "; it is flashing the output box once and then it will go away. It wont stay up and on the screen for a split second then it will go away. Not sure why it is doing that.
what compiler are you using?
try the built in calculator of your computer to see more precise computations
and the install cost comes out as 99.83
actually computations comes out correctly since it accurately computes for the answer which is 99.826388888... and is rounded of as 99.83
assign it after I call the area function?
Did you do it like this at main.
//call compute area to preform the nessecary calculations and return the area
area = computeArea(width, length);
I assigned it after the call and passed the two variables in the last function but I am getting 0 values for the report.
If you've already done something like this at the last function,
void computeCosts(double &totalCarpetcost, double &instalcost, double carpetPerfootcost,double area )
Did you already fix the function prototype to match the function, checked the values of area and carpetPerfootcost at main(before function call),at the function?
I Tried the program on my end and got it to work
assign the value returned by computeArea() to variable area at main
then pass the variables carpetPerfootcost and area and to the last function
if you check the values of name at line 15 you'll see that they're all null
@ the Monitors class constructor try to use the parameters passed instead of assigning to itself
also your exporting a non public type, try to make class Monitors public if it's not in the InventoryPart3rd class
check the toString() method
hmm I tried compiling it in linux gcc and in pelles C using cygwin and didn't get any errors... even when separated
did you try my last post?
contact *newnode;
newnode = (contact*) malloc (sizeof(contact));
your not reading the file word by word... judging from the current code, it will only check the first word of the files
use a loop that will get the words from the file until it reaches the EOF
@ line 19: you mistook a while loop for a for loop
@ line 26: you forgot to put << before year
the files differ statement only occurs if the first word is different, otherwise it won't print the statement
the files are equal statment occurs only if the first word for each file are the same
printf("files differ: word %d", wordCount);
return 0;
when you used the return statement, you ended the loop and function
allocate memory using the new operator and save the address of that memory in the pointer.
you can try it like this;
int* nums = NULL; // Pointer to int, initialize to nothing.
int total;
cin >> total;
nums = new int[total];
for (int i=0; i<total; i++)
{
cout << "Enter number" << i+1 << ":";
cin >> nums[i];
}
don't decrement the value of i by 1 every time you only need to use j n the operation...
something like this:
while (i>50)
{
cout << i << " ";
j++;
i-=j;
}
Also, what if I wanted to write a loop where each number is subtracted by one more than the one before it (100, 99, 97, 94, 90...)?
use a counter that increments itself, then you use this counter to subtract the main variable
Not really having a certificate means that your well versed with the languange
It's just that you can't brag much about it when it comes to finding a job
In what way can we help?
if(filename == "quit")
use strcmp
At the get input functions use the variables you passed on to those functions
assign values to the variables and return them
then at main, assign values to op1, op2 and opr using those functions like
op1 = getOp1(op1);
use cout statements after these to make sure you got the correct values
yes it's the for loop, the value of distance and time doesn't change
to fix this you need to make use of the counter as a substitute for time
I am not certain, but I do not think that
if (opr='+',...)
works. I would suggest trying:if (opr='+'||opr='-'||...)
that's what == operator is for right ;)
if (opr = '+','-','*','/','%','^')
use the == operator for comparing values
Divide into different statements and Compare opr with each operand
and use || for all the statements comparing opr with a single operand to check if at least one of these statements is true
I meant like this:
System.out.printf("%d\t\t%.2f\n",counter + 1, wages[counter]);
and next time wrap your code between
tags so I can tell exactly which line I needed to point out
no, I meant at those printf statements only
The array has to display 1-10 i mean rather than 0-9
Add +1 to counter when printing
Also, I try to test the while loops with negative or 0 inputs, and I get a repeat of the output which looks like this:
Why not ask for the input again instead of just incrementing the value?
It doesn't display the 1 hour which it's supposed to be 50 miles traveled.
The value of time and distance doesn't change use the counter i instead and you need to incorporate the formula in the loop to display the correct miles per every hour
In short Dynamic allocation
Too bad C doesn't have an ArrayList class like Java or Vector like in C++ ;)
Can you answer these first
first, you'll need to check for yourself, how deep and correctly you're willing to go: for instance:
2 + 6 * 3 = ?
will you use the correct order? meaning
2 + 18
or are you 'content' starting off with first getting everything done, like
8 * 3also, will you take into account the use of '(' and ')'?
next if your still using that code, I believe that just adding lines of codes won't be enough for this. There's gonna be a lot of changes... how about checking examples for calculators made in java from the web
what do you mean by unfix size array?
in java arrays you'd still need to allocates memory for the elements
can you be more specific or give an example about that?
System.out.printf("\n%s\t%11s\n\n","REP","SALARY")
System.out.printf("\n\n\n%s\t%10\n\n","BONUS","TOTAL");
These are wrong, the arguments used here are not variables
1.Initialize the variables bonus and total array as double(no need to change variable counter as a double)
2. use %f at the printf statements for the variables which are double
3. use these for precision
bonus = (double) wages[counter]/100*30;
total[counter] = (double) wages[counter]+bonus
4. use code tags next time