|
-
Oct 25th, 2006, 01:08 AM
#1
Thread Starter
New Member
Two questions
What is the relationship between MenuStrip control and ToolStripMenuItem control.
2nd question:
how do i complete the following statement so that it calculates average score as a floating point number with double precision? I have two int variables, the first is total, the sum o the scores on the exam, and the 2nd int is count, the number of exams
-
Oct 25th, 2006, 01:26 AM
#2
Re: Two questions
One thing to note is that neither the MenuStrip or the ToolStripMenuItem are controls. A MenuStrip is the menu you see at the top of a form. From the name, what do you suppose a ToolStripMenuItem is?
How would you calculate the average if you were doing it on paper? It's basically the same in code. This sounds a lot like homework so I'm not going to provide code, but if you don't know how to calculate the average from a sum and a count then you should ga and speak to your maths teacher.
-
Oct 25th, 2006, 01:36 AM
#3
Thread Starter
New Member
Re: Two questions
i was confused with problem 2 because it asked as a floating-point number with double precision. I know how to do the division, i just didnt know what the floating point number with double (I am guessing real number) precision meant exactly.
For problem 1 i was confused because the question says they are controls but I didnt think they really were.
It is a class I have to be exactly correct with my wording or else i get point taking off.
-
Oct 25th, 2006, 01:40 AM
#4
Thread Starter
New Member
Re: Two questions
I am guessing it is
double average = Convert.ToDouble(total)/ count;
-
Oct 25th, 2006, 01:49 AM
#5
Re: Two questions
Actually, wash my mouth out with soap. The MenuStrip is indeed a control. I was thinking of the old MainMenu class, which was used in .NET 1.x and was basically replaced by the MenuStrip. The ToolStripMenuItem is definitely not a control though. To be a control a class must inherit, either directly or indirectly, from the Control class. Menustrip does infirectly inherit Control but ToolStripMenuItem does not. I suggest that you read the MSDN help topics for each class.
For the second question, a double precision floating point number is just an object of type double. Note that the C default behaviour when dividing an integer by an integer is to return an integer, even if the actual value would have had a fractional component. To force the result to type double and retain the fractional part you must convert at least on of the integers to a double. You can do that with a cast or using the Convert.ToDouble method.
Edit: beat me to the second one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|