Showing posts with label Fundamental C#. Show all posts
Showing posts with label Fundamental C#. Show all posts

Simple Calculator Windows Form C#

Hello, this is my lab 2 exercise.
You can use it for simple calculating :)
Hope you will like it......
Level: Easy
Time: 6 hours





Requirements:

__________/100

  1. Implement a mathematical calculator similar with a scientific calculator with the following requirements:
    1. The application is a control box
    2. No minimizing and maximizing buttons
    3. Use containers (group boxes and panels)
    4. Create your icon (use Visual Studio or the editor of your choice to create the icon)
    5. “On” button starts the calculator.
    6. The calculator performs minimum four operations: addition, subtraction, multiplication and division.
g.       If you enter a number by mistake, you can use CE to clear only the current operand. It does not clear previous calculations. C deletes all. Backspace deletes the last digit.
    1. Don’t store the operations and numbers in a string/array! Use events, the SendKeys class to get the keys and the operators values or use the Sender and the same handler for several keys.
    2. Create a picture box that will load an image or paint a rectangle.
    3. Add the image as a resource. 
    4. Identify what exceptions are needed and add them to your code.
  1. Test your calculator on a different resolution
  2. Use good programming style:
    1. Comments
    2. Meaningful naming
    3. Bloc descriptors for classes and procedures: use XML comments
    4. Mark the assemblies as CLS-Compliant.

Bonus:
__________/25

a.       Implement memory functions to solve brackets and order of operations.
b.      For some calculations, you may want to remember one calculation to use later. You can add a calculation into memory by clicking the M+ button. Then you recall it later with the MR button. You clear the memory with the MC button.
c.       Note that M+ will add whatever you have on the display to whatever is already in the memory, so it is good to click MC before adding with M+, unless you have recently started the calculator.
d.      The MS button stores the currently displayed result in memory. In the case when you display only the most recent operand, MS and M+ serve the same function.


Example: You want to add 1 + 2 and then multiply that by the sum of 9 - 2
Click C to clear all.
Add 1 + 2 and click =
Click MC to clear the memory, then click M+ to add the value to memory.
Click CE to clear previous addition.
Then enter 9 - 2 =
Click * to multiply by another number.
Click MR to recall what is in memory. Then click =

You should get a total of 21.

Hello World Windows Form C#

Hello, 
It's me, Thanh. Now I am in third term CST.
This is my very first lab for the fundamental C# course.
Level: Easy
Time: 2 hours
(As usual, I attach all the source code for you all)








Requirements:

Explore Visual Studio 2012 implementing the Hello World application.
    1. The application should display Hello World at an event (button click).
    2. If the application is minimized, it will appear on the system tray and not on the task bar.
    3. The application has the “x” in the right corner overwritten; it will instead minimize the application and put the icon on the system tray.
    4. The application can be closed from an exit menu.
    5. The user will be notified.
Hints: For solving this assignment read the MSDN documentation at:


C# types

1. A C# program is a collection of types: classes, structs, enums, interfaces, delegates, etc.
2. Pre-defined data types: int, byte, char, string, object, etc. Similar to other language, we can create our own types. There are no global variables nor global functions.
3. Type contains:

  • Data member:
    • Fields, constants, arrays
    • Events
  • Function member:
    • Methods, operators, constructors, destructors
    • Properties, indexers
4. There are 3 categories of types:
  • Value: directly contains data on the stack, cannot be null
  • Pointer (only in unsafe mode)
  • Reference: contains references to objects, may be null. (keeps a reference on the stack, but allocates the real memory on the heap) 
 

Copyright © 2013-2014 Lai Duy Thanh All rights reserved.