CMPS 3350 Lab-8
Program writing and testing methods
Programming is to be done in your own Odin 3350/8 directory. You may start with your program from Monday: 3350/8/add.cpp The scenario... Your software company needs to provide this critical solution to a large customer, and the product must work perfectly. Write a C or C++ program that will... 1. Generate some rows of numeric digits. Use the random number generator. 2. Ask the user for the number of rows and columns of digits. 2x4 would look like this... 6580 5026 3. Treat each row of digits as a single number. Show the sum using addition. Example: 6580 5026 ---- 11606 <--- sum is there Format of program output should look like this...Lab-8 add up large numbers -------------------------- Enter rows & columns: 2 5 13463 75385 ----- 88848 program complete.You may also get user input using command-line arguments.
As you start to get this working, think of how you will go about testing the program. What if your client enters a 16 by 88 problem like below. Is the answer correct? 6580502614843921451552883757884464615808482787122299478765645111773283023501215636674660 1376688353656889383710647233013142920768043841081552738453955381784872808102520878371339 7364875551343143576098098362791629006563910434801423422388557812912880172127807169403851 6286098222013307744743824557301239051073296739423090592947900045142242881466528957909123 1353398650994986364183052981207532884849151549105615131341761426824410648794834517222576 6637273319742580284211740083559244161795699848896519613831108322761130611506507378251744 0751093076309940646463764015972057178696328212208147613236034251168140792816066992675101 7241612793033035863849933539650676739228741244923317223886961120725647631758440773626906 7140272117976508256818792438556560789090707457494208077232217065133054136071012632450305 5464549604850986277200854314632478825805292303922943150501284424216917636986409695902074 3930374800719475574975562585761054014694768627474062528999665882413872561353013619883974 8425419843737200776989510414588541084178463403492080153214863819138757713155424742969501 9874814064711556621245199378871979452078652929501846587636615822989187164558428624472355 9284038117424788346986711305663783106910952320476095968208784264894617604839176907694436 3049524320138834883182189793421946810262387360741169397488820116908044292248425553404342 1473680500574067237654229823468535193346325723646621265257796569090624256750016999027844 ---------------------------------------------------------------------------------------- 86234215952071223289866994586344865835151204784310992943391971437877683936035831079940131
Suggestions for writing this program... 1. Setup an array to store each digit of the sum. 2. As each random digit is generated, add it to the sum. Think about elementary school addition. 3. Use carrying. This will require a modulo operation and a division. 4. Start with very small rows and columns for easy visual testing and debugging. ==================================================================== NOTES: Files to be collected from Odin: 3350/8/mylab8.cpp 3350/8/Makefile Your C/C++ file will be collected at lab end, 9:50am. Please make sure your program compiles and runs. If it is not finished, continue to work on it, but make it compile when collected. ====================================================================
You graduated and started your own software development company. Your company needs to provide this critical solution to a large customer, and the product must work perfectly. 1. List all the ways that this program might be tested. 2. Write your ideas on paper and hand it in when class begins Wednesday. 8.5 x 11 inch paper is best. Neatly done. Readable. 3. List your testing ideas and methods. 4. Number your ideas. 5. Be brief. Do not go on and on. ============================================================================ Warning, do not read an article on software testing and list things like black-box testing, white-box testing, unit testing, acceptance testing, intgration testing, regression testing, functional tests, end-to-end tests. These will not be accepted. ============================================================================ Briefly describe how you would test this program. You are the company owner and can decide how software should be tested. Do not show any code to test the program. You have to guarantee to a large client that the program works. List as many testing methods you can think of. Samples... These are bad testing methods, except one. 1. Run the program over and over. 2. Run only small tests that can be easily proven correct. 3. Ask the programmer if there are any bugs in the code. 4. Ask a trusted mathematician to validate the program output. Now, add more to your list. A few good testing methods require coding by the programmer, and some do not.
Finish your programming, and get the program working. No compile warnings or errors are allowed. Add the following options to your g++ compile command... -std=c++11 -ansi -pedantic g++ mylab8.cpp -Wall -std=c++11 -ansi -pedantic Now make your program work.