CSci 1113 C++辅导、讲解 Introduction to C/C++ C++留学生辅导 C++解析 C++程序,C++讲解

- 首页 >> C/C++编程


CSci 1113: Introduction to C/C++

Programming for Scientists and Engineers

Homework 0

Fall 2018

Due Date: Wednesday, September 19, 2018 before 11:00pm.

Instructions: This is an individual homework assignment. There is one problem worth

20 points. Solve the problem below by yourself (unlike the labs, where you work

collaboratively), and submit the solution as a C++ source code file. Here are a

few more important details:

1. Unlike the computer lab exercises, this is not a collaborative assignment. You must

design, implement, and test the solution to each problem on your own without the

assistance of anyone other than the course instructor or TAs. In addition, you may

not include solutions or portions of solutions obtained from any source other than

those provided in class: examples from the textbook, lectures, or code you and your

partner write to solve lab problems. Otherwise obtaining or providing solutions to

any homework problems for this class is considered academic misconduct. See the

“collaboration rules” file on the class website page for more details, and ask the instructor

if you have questions.

2. Because all homework assignments are submitted and tested electronically, the following

are important:

• You follow the naming conventions mentioned at the end of the problems.

• You submit the correct file(s) through Moodle by the due deadline.

• You follow the example input and output formats exactly given in each problem description.

• Regardless of how or where you develop your solutions, your programs compile

and execute on cselabs computers running the Linux operating system.

3. The problem descriptions will usually show at least one test case and the resulting

correct output. However, you should test your program on other test cases (that you

make up) as well. Making up good test cases is a valuable programming skill, and is

part of ensuring your code solution is correct.

Problem A: Torus (20 points)

Make a simple program that asks a user two radii (in the fashion shown below). These radii define a

torus (“doughnut”), where the first is the radius from the center to the center of the torus (‘R’ in the

picture below) and the second is the radius defining the thickness of the torus (‘r’ in the picture below).

Then display first the surface area and the volume in the format shown below. The relevant formulas

are:

Note: we will use test cases to assist in grading the homework. Please ensure that you follow the format

below to make the graders’ lives easier. You can also assume we will only enter values where: ‘r’ < ‘R’.

Example 1 (user input is underlined for clarity, underlined text in your program is not needed):

Large radius:

2

Small radius:

1.5

Surface Area:

118.435

Volume:

88.8264

Example 2 (user input is underlined for clarity, underlined text in your program is not needed):

Large radius:

22.5

Small radius:

2

Surface Area:

1776.53

Volume:

1776.53

Test your program using not only the example data above, but other cases as well. And

revise your program until you are sure it is correct.

When you are done, name the source code file <username>_0A.cpp. Here you replace

<username> with your U of M email address; for example, if your email address is

smithx1234@umn.edu, your file should be named smithx1234_0A.cpp. Then submit your

program using the HW 0 Problem A submission link in Moodle.

It is important that you follow the file naming conventions very carefully. For example,

note your username should be all in lowercase, you should not include “@umn.edu”, the file

name should contain an underscore (not a dash), the ‘A’ in the “0A” part is upper case,

the extension is .cpp, etc. Following rigorous naming conventions is something computer

programmers often must do in “real life” programming, and so submitting your program

with the correct name is part of doing this assignment correctly.


站长地图