Cab201 programming principles

Page 1

Locus RAGS Shubham Mishra

CAB201 Programming Principles Your program will prompt the user to select the desired calculation, voltage, current or resistance. The menu will include an option to quit the program.


CAB201 Programming Principles First Assignment Weighting 10% Due date: 18st March, 2016 before 11am. Specification You are required to write a menu-driven program which will allow the user to calculate any one of three quantities given the other two quantities. Ohm’s law deal with the relationship between voltage and current in an ideal electrical conductor. Voltage = Current * Resistance Your program will prompt the user to select the desired calculation, voltage, current or resistance. The menu will include an option to quit the program. The program will then prompt the user to enter appropriate values for the other two quantities. For example if the user selects to calculate the resistance the program will prompt for the voltage and the current and then output the resistance value. The program will then prompt the user if they wish to repeat the calculation by changing one of the two input values. If user responds positively, they will be prompted for what input value to be changed and then the new value for that quantity. If the user does not want to repeat that calculation, the main menu will be redisplayed. The standard metric units for each are as follows: Voltage: volt Current: amp (actually amperes) Resistance: ohm We will assume that the minimum value for each quantity will be as follows: Voltage:

0 volt

Current: 0.01 amp Resistance: 10 ohm There is no upper limit for any of the values. You can assume that the user will not enter a value greater than double.MaxValue for any quantity. Assignment Goals The assignment problem is straightforward. The solution of the problem will be a C# project consisting of a single class which will use programming constructs covered in Lectures 1 & 2. You are free to use any valid C# programming construct, even if it has not been covered in lectures except for the “goto” statement. Use of “goto” will result in your assignment mark being downgraded substantially by at least 1 grade level. Though the code could be written as straight line code, the sheer number of lines would make the solution difficult to read, hard to


understand, hard to maintain, hard to modify and more than likely to contain potential logical errors. A straight line code solution will not receive full marks even if it fulfils the required functionality. The body of the Main method should resemble a high-level algorithm with minimum low level C# statements. There should be no input/output statements in Main. You are required to use methods (void and value returning) to provide a structure to your solution. Your program should consist of only one class containing at least four (4) methods not including Main and trivial methods such as ExitProgram() and Welcome() as seen in Lecture 2. The additional methods should be a mixture of value-returning and void methods. There is no upper limit on the number of methods used. Sub-goals of the assignment are to experience: 

Top-down design & development

Incremental Development & Incremental Implementation

Translating simple algorithms into C# code

Writing user defined methods

Parameter passing

The mechanics of editing, compiling (building) and running your program

Testing your program

Becoming confident and comfortable with programming in the small Electronic Submission You will submit your assignment via the link in the Assessment folder on Blackboard (Bb) before 11am on Monday 21 st March 2016. Detailed information on the assignment submission is available on Bb in the document, First Assignment Submission Details.docx, It is recommended that you upload your file to Bb from a worksttaion at QUT. Inability to access Bb from home is not a sufficient reason for submitting the assignment late or requesting an extension. Plan to be finished well before the afternoon of 20 th March! You should avoid writing all of the code in one sitting and then attempt a build (compilation). Remember Incremental Development and Incremental Implementation. Final Comments This assignment is not about screen design so do not waste time attempting to produce the fanciest looking screen output. Though you are free to alter and enrich the output statements it will not gain any additional marks. The basic console interaction as seen in lectures and in workshops is sufficient, as long as it is readable. There are no marks for “pretty” or ‘clever” screen interactions. Enjoy the experience of this assignment!


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.