CS1026: Assignment 2 – Volume Calculator
Volume Calculator代写 Due: October 16th 2019 at 9:00pm Weight: 8%Learning Outcome:By completing this assignment, you will gain skills relating
Due: October 16th 2019 at 9:00pm Weight: 8%
Learning Outcome:
By completing this assignment, you will gain skills relating to
- usingloops,
- usingfunctions,
- using lists inPython,
- creating and using Pythonmodules,
- testing,
- following program specifications and
Task:Volume Calculator代写
In this assignment, you will write a complete program in Python that computes the volume for cubes, pyramids and ellipsoids. Your program should make use of functions, loops, and lists.Volume Calculator代写
Your program will consist of two files: one is a module, volume.py, which computes volumes and the other is a main program, main.py, which uses the functions in module volume.py. The program is expected to prompt the user for a type of object (e.g. a “cube”) and validate that is one of the expected object types before computing the volume. In addition, your program should keep track of each volume that is calculated. After the user chooses to “quit” your program should display the volume for all the shapes AND you should use the function summarize to output your lists to a file; the function summarize is provided for you in a module summarize.py. You are to test your program on three different test cases which are provided for you.Volume Calculator代写
Functional Specifications:Volume Calculator代写
- Your main module, py,should handle the prompting and input for the different shapes and the output. Specifically, it should:
- Prompt the user for the shape they are interested in, check to make sure that their inputis Valid input options are: “cube” or “c”, “pyramid” or “p”, “ellipsoid” or “e”, “quit” or “q’; you should accept the input in any combination of upper and lower case letters. If the user enters an invalid option, your program should continue to prompt the user for a correct choice.
- Yourprogram should continue to prompt the user for different shapes until the user enters “quit” or “q’.Volume Calculator代写
- Yourprogram should prompt the user for the necessary dimensions for each of the respective shapes. You may assume that the user enters positive integer values and so you DO NOT have to check the input for valid
- Once your program has a valid input, it should then use the correct function in pyto prompt the user for the specific values for that shape and compute the volume (see below).Volume Calculator代写
- It should then add the resulting volume to a list of volumes for the same kinds of shapes(i.e., all cube volumes will be in the same list).
- Once the user has entered “quit” (or “q”), your program should sort each list from lowest to highest. It should then print the list of volumes for each shape in sorted order and pass the sorted lists to the function
If there are no calculations are done for a specific shape then a statement should be printed. For instance if there were no pyramid calculations the output would be as shown below.Volume Calculator代写
The volumes calculated for each shape are:Volume Calculator代写
Cube: 125.0, 1953.125
Pyramid: 200.0
Ellipsoid: No shapes entered
If the user enters quit option before actually calculating any volumes print a message indicating that no volumes were computed, such as:
You have reached the end of your session. Volume Calculator代写
You did not perform and volume calculations
- Yourmodule, py, should contain the functions for computing the volumes.Volume Calculator代写
- Each of your functions should calculate the volume of the shape and return that value (it should not print a message); volumes for the different shapes are computed as follows:
3.The function summarize in the module py is used to output the results to files.Volume Calculator代写
The function summarize has 4 parameters: summarize(clist,plist,elist,testNumber). The parametersare, respectively: the list of cube volumes, the list of pyramid volumes and the list of ellipsoid volumes. The last parameter is the test case number (Hint: when you write your program prompt for the test case number before you start to prompt the user for shapes and dimensions) . You must test your program on the following three test cases:
- Testcase 1: use the following (in order) for the different shapes:
- Cube: length of side:11
- Pyramid: base = 10; height =12
- Ellipsoid:radius1 = 10; radius2 = 6; radius3 = 9Volume Calculator代写
- Testcase 2: use the following (in order) for the different shapes:
- Ellipsoid:radius1 = 6; radius2 = 7; radius3 = 8
- Ellipsoid:radius1 = 1; radius2 = 1; radius3 = 1
- Cube: length of side:1
- Pyramid: base = 1; height =3
- Cube: length of side:9
- Cube: length of side:5
- Pyramid: base = 12; height =12
- Testcase 3: use the following (in order) for the different shapes:
- Pyramid: base = 10; height=13
- Pyramid: base = 1; height =1Volume Calculator代写
You will notice that the function summarize outputs a file with your results. It creates a filename with the test case number that you provide. For the three test cases you should end up with three files: Asgn2TestCase1, Asgn2TestCase2 and AsgnTestCase3.
Non-functional Specifications:
- Include brief comments in your code identifying yourself, describing the program, and describing key portions of the Volume Calculator代写
- Assignments are to be done individually and must be your own work. Software may be used to detect
- Use Python coding conventions and good programming techniques, forexample:
- Meaningful variable and functionnames,
- Conventions for naming variables andconstants,Volume Calculator代写
- Use of constants whereappropriate,
- Readability: indentation, white space,consistency.
Submission requirements: What to submit:
You should submit your files volumes.py and main.py as well as the three files Asgn2TestCase1, Asgn2TestCase2 and AsgnTestCase3 with the results of your testing. Make sure you upload (attach) the files; DO NOT put the code inline in the textbox.Volume Calculator代写
What You Will Be Marked On:
- Functionalspecifications:
- Are there modules volumes.py and main.py and are they defined according to specifications?
- Is the function summarize usedcorrectly?
- Doesthe program compute according to the specifications?
- Doesthe program handle invalid input for the type of object?
- Is there an effective use offunctions?Volume Calculator代写
- Is the output according tospecifications?
- Havethe files with the test cases been created and submitted?
- Non-functional specifications: as describedabove
- Assignmentsubmission: via the OWL, though the assignment submission in
更多其他:C++代写 考试助攻 计算机代写 report代写 project代写 数学代写 java代写 程序代写 algorithm代写 代写CS 代码代写 function代写 作业代写 物理代写 金融经济统计代写 Data Analysis代写 python代写