Results 1 to 5 of 5

Thread: Two questions

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    4

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    4

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    4

    Re: Two questions

    I am guessing it is

    double average = Convert.ToDouble(total)/ count;

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width