Presentation is loading. Please wait.

Presentation is loading. Please wait.

In-class program development 1 You are to develop a simple calculator which will allow the user (you, also) to perform the following operations: The first.

Similar presentations


Presentation on theme: "In-class program development 1 You are to develop a simple calculator which will allow the user (you, also) to perform the following operations: The first."— Presentation transcript:

1 In-class program development 1 You are to develop a simple calculator which will allow the user (you, also) to perform the following operations: The first thing your calculator must do is present the available operations to the user (Note this must be done in a different (from the main) function One additional operation that the menu must offer is the option to quit the calculator (i.e., the program should keep presenting the options until the user decides to quit) Once a ‘valid’ choice is made the function should return the choice to the main function If the choice is not valid, you should remain in the menu function until a valid choice is made Depending on the choice, you should ask the user to enter either 1 or two integers (this should be again accomplished in a function different from the main function) Now you should perform the operation chosen, using the integers chosen. Each operation should be performed in a separate function. In that separate function, you should also print out the result of operation. Keep in mind that you will also have to check for illegal requests (e.g., division by 0; converting a negative integer to binary) – think about what other operations are illegal Operations AdditionDivision (Remainder) SubtractionDivision (Real) MultiplicationOdd/Even Integer ExponentiationDecimal to Binary Division (Quotient)

2 Remember what we discussed: Every function should be short. Plan your program so that it contains less than ten lines (or so – this is not a number fixed in stone). Keep in mind that this program will require multiple loops (either a while/do-while or for). Think about which you think is most appropriate) Keep in mind that the the program can only terminated in the main program. You can ONLY use integers (short or int) All of your variables MUST be local I mentioned earlier that if you go on-line, you will find multiple sites that offer this code. For example http://stackoverflow.com/questions/18049095/first-c-program-help-calculator I have found many more of them. If I see the exact same code in your program, I will send your program to the Dean of Students. Also if I notice that any 2 or more students have submitted exactly the same program, I will send them to the Dean of Students http://www.thefreedictionary.com/plagiarism Failure to follow any of the requirements listed above will result is significant deductions from your grade In-class program development 1

3 Most of you will have trouble with the decimal to binary function. Below you will find one example. You can make changes to it. If you do not thoroughly understand how this function works, you will probably have a lot of problems with the next test.

4


Download ppt "In-class program development 1 You are to develop a simple calculator which will allow the user (you, also) to perform the following operations: The first."

Similar presentations


Ads by Google