|
|
Ok, so thanks to the help I have the program working somewhat correctly, I think. It has 2 loops, a for and while.. one allows the user to keep inputting data into an array that will be defined by the user in size but is no more than 50 values. I have a while loop in this that will ask user to input 1 to continue, 0 to stop entering temperatures. My problem is, I think the values are being stored correctly cause when i choose to output say myarray[0] the correct value I input comes up, but I want to be able to print out how many actual arrays there are in a statement like "Number of readings entered is 12," not the values in them (although I hope i stored each one properly).
This is where I am stuck. From here I have to take the data and make sure its all in centigrade. Im pretty sure I can write a basic function to do this part, but how do I make a statement to call this in my loop as the user inputs functions, and then prints out how many there are? Any help much appreciated thanks.
// Computer Lab test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
double myarray[51];
int i;
int flag;
flag=1;
for(i= 0; i < 50; i++)
while (flag==1)
{
// loop to enter temperatures - pressing 1 continues, pressing 0 stops //
cout << "Enter Temperature Reading:";
cin >>myarray[i];
cout << "Enter 1 to input more values, 0 to stop";
cin >>flag;
}
std::cout << myarray[i] << std::endl;
return 0;
}
|
|
|
|
|
planetx22 wrote: for(i= 0; i < 50; i++)
while (flag==1)
{
// loop to enter temperatures - pressing 1 continues, pressing 0 stops //
cout << "Enter Temperature Reading:";
cin >>myarray[i];
cout << "Enter 1 to input more values, 0 to stop";
cin >>flag;
}
Modify the above code to the following...
for(i = 0; i < 51 && flag == 1; i++)
{
cout << "Enter Temperature Reading:";
cin >>myarray[i];
cout << "Enter 1 to input more values, 0 to stop";
cin >>flag;
}
cout << "Number of elements in the array is: " << i;
|
|
|
|
|
Ahh.. of course I don't know why I didnt see that before thank you very much. The next thing I need to do is use a function i previously made to convert the values entered in array from fahrenheit (if they are) to celsius. Im just not sure how to make the computer know if the values entered are fahrenheit or not (i know the math formula, just not how to use it). Any help much appreciated thanks.
|
|
|
|
|
planetx22 wrote: The next thing I need to do is use a function i previously made to convert the values entered in array from fahrenheit (if they are) to celsius.
See here[^]
|
|
|
|
|
thanks alot.. got me on the right track i think.
My function goes like -
double my func(double fahrenheit)
{
if (fahrenheit>100) fahrenheit = 1.8 * celsius + 32;
return fahrenheit;
};
Im just not sure how to make the value the user enters into myarray[0-50] go into fahrenheit and then do the check, then return the value to the array either fixed with the formula or not because it was not greater than 100.
Can I do something like in my for loop before the user chooses to continue or stop, or is that the wrong spot? And would it be something like -
myarray[i]=my func(myarray[i]; ?
Thanks alot for the help.
|
|
|
|
|
planetx22 wrote: Im just not sure how to make the computer know if the values entered are fahrenheit or not...
It can't. If you simply see 35o, how would you know whether its F or C? You might want to ask the user what they will be entering before the for loop.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi, all
Message WM_PAINT is resposed and DrawItem is also overloaded in CMyListCtrl.
and the style of LVS_OWNERDRAWFIXED is added into CMyListCtrl.
I draw figure A in OnPaint() and figure B in DrawItem(), the result is figure A is presented. If I delete the WM_PAINT message handler, B is presented. could anyone here explain this for me if I want to draw A and B both in OnPaint() and DrawItem respectively?
|
|
|
|
|
zouchao1112 wrote: I draw figure A in OnPaint() and figure B in DrawItem(),
Why?
zouchao1112 wrote: If I delete the WM_PAINT message handler, B is presented.
Naturally, someone has to send the draw item message, since you have overridden WM_PAINT you are the one who should do it.
|
|
|
|
|
Hi all,
How can I change the height of the header in list control having report view?
Thank you.
- NS -
|
|
|
|
|
NS17 wrote: How can I change the height of the header in list control having report view?
Doesn't sub classing of header control help?
|
|
|
|
|
But my problem is if I reduce the height the list control items will not be shifted to up. So there will be blank space between header control and first list item.
- NS -
|
|
|
|
|
NS17 wrote: But my problem is if I reduce the height the list control items will not be shifted to up. So there will be blank space between header control and first list item.
This[^] thread has some suggestions you can try them.
|
|
|
|
|
What if you set a big font to the list control?
nave
|
|
|
|
|
I can't change the font size for this.
-- modified at 3:10 Thursday 5th April, 2007
- NS -
|
|
|
|
|
|
Thank you. I think it will help me...
- NS -
|
|
|
|
|
Hi,
i have a problem like you, but not for the header control, i need to change the list's row high,
sometimes i need to set a new high for the row in runtime, mean, any time over a buttonklick to set
new row hight for some rows, not for all, lets say, rows wit specified text should have row high 0(invisible), did you ever work on them?
tnanks
termal
|
|
|
|
|
Mm... I had to do such a thing before. At that time I did simply create a new control from CWnd...
- NS -
|
|
|
|
|
Hi all.
I have ToolBar and I wont to see it in my dialog.
How I can add this toolbar to my dialog window?
|
|
|
|
|
You will get a lot of samples for this in CP.
see this[^]
- NS -
|
|
|
|
|
|
david bagaturia wrote: How I can add this toolbar to my dialog window?
Use RepositionBars .
|
|
|
|
|
|
Hi,
i created 2 projects. i was able to run the projects sucessfully.
than i replaced the source and header files of one project with newer version.
compilation is sucessfull.
but when i run --LINK : fatal error LNK1104: can't open File 'fskaren.lib' .
where fskaren is one of the project name.
building of fskaren is sucessfull.
please guide me
Help Ever Hurt Never
|
|
|
|