Starting from:

$30

HOMEWORK 1 There is no Nobel Prize in computer science

HOMEWORK 1


NOTE: Homework will be graded on build.tamu.edu using g++ 5.3.0 with
-std=c++14. You are free to develop your programs on Visual C++ or any other
platform, but it is your responsibility to make sure your programs also compile
and execute correctly on build.tamu.edu using g++ -std=c++14.

The grade for this lab will be based on style (formatting, variable names,
comments, etc.), syntax (no compilation or link errors), and correctness
(passes all test cases). Follow the style guide at
http://www.stroustrup.com/Programming/PPP-style.pdf. Your grade for this lab is:
Problem # 1 2 3 4
Style /2 /4 /4 /2
Syntax /3 /6 /6 /3
Correctness /5 /10 /10 /5
-------------------------------------------------------------------
Total /10 /20 /20 /10
Grand total _____/50

1. (10 points) There is no Nobel Prize in computer science, but there is the
Turing Award by the Association for Computing Machinery. Posters of all the
Turing Award winners are in the halls of the buildings used by the Department
of Computer Science and Engineering, namely, the 2nd, 3rd, 4th, 5th floors of
HRBB, the 2nd and 3rd floors of Teague, and Reed McDonald. Visit these
locations and write down 15 Turing Award winners' last names and the nearest
room number, then make a completed crossword puzzle on paper by interlocking the
last names. List the room numbers as the clues. For example, here is a
small crossword puzzle using Frederick Brooks and Donald Knuth:

DOWN 2. Teague 326 (Note: This is an example, not the correct room number)

ACROSS 1. HRBB 312 (Note: This is an example, not the correct room number)

1 2
B R O O K S

N

U

T

H

Now write a C++ program named hw1pr1.cpp which prints the clues and the puzzle
using lots of cout statements. Do not turn in the completed crossword puzzle;
running your program will display it on the screen like the example above,
except yours will have 15 names.

Hint: Use 1/4-inch graph paper to lay out your completed crossword puzzle on
no more than 24 rows of no more than 80 columns each. You can print your own
graph paper at http://www.printfreegraphpaper.com.

2. (20 points) With one cut across the middle of a pizza you can cut off half, that is, 50% of the pizza. With one cut at a different place you can cut off
less than 50%. The length of the cut is called the "chord" and the piece
removed is called the "segment."

Look up (or derive yourself) the formula for the area of a segment in terms of
the chord length and the diameter, and write a C++ program to ask for the chord
length in inches and print out the percentage of a 14" pizza remaining after the
segment is cut off. Running your program should look like this:

Pizza diameter is 14".
Enter chord length in inches: 0
That cut leaves 100% of the pizza.
Enter chord length in inches: 14
That cut leaves 50% of the pizza.
Enter chord length in inches: 10.17
That cut leaves 90% of the pizza.

Use while(cin chord) so the program will keep reading and calculating until
end of file. Name your program hw1pr2.cpp. Reminder: If you did not derive
the formula yourself, state in a comment where you got the formula.

3. (20 points) Chapter 4 Exercise 8, using int. Name your program hw1pr3.cpp.

OPTIONAL EXTRA CREDIT
=====================
4. (10 points) Modify problem 3 to print the exact number of grains on all 64
squares. Use unsigned long long instead of int. (Note: This works on our
two compilers, but may not work on other C++ compilers.) Name your program
hw1pr4.cpp.

More products