Assignment #1
Due: Friday, Sept 22
Objectives
- To practice with writing a small C++ main() program, along with
compiling and running it
- To practice with basic C++ input/output features, along with some
simple decimal formatting
- To practice with basic arithmetic operators in C++
Task
Create a program (Filename: paint.cpp) that will
calculate the amount of paint needed to cover
one side of a house with a sloped roof.
- Assume that this side wall of the house is generally shaped as in the
diagram below (with rectangular lower section, and triangular section
where the roof slopes to a point) and that it contains one rectangular
window, which does not get painted (obviously).
- As you can see in the sample execution, you should ask the user for
the dimensions of the wall (width, height to the bottom of the slanted
roof, height up to the tip of the slanted roof) and the dimensions of the
window (width and height) -- in this order. All of these dimensions
should be of type
double
- Assume that a can of paint will cover 400 square feet of wall
(make this a constant integer variable, so that it's simple to change
this value in the program -- for example, to represent larger cans of
paint in future versions).
- After collecting all of the dimensions, your program should produce
the output demonstrated in the sample execution. Also note that:
- The user-entered dimensions should be displayed in default format
(only using a decimal point and digits to the right when needed)
- The paintable area should be displayed to 1 decimal place
- The required number of cans should be displayed to 2 decimal
places
- Write your program so that the output looks EXACTLY like
the sample execution shown below (this means same wording, spacing,
and formatting of numbers)
- Note: The underlining in the sample execution below is used to
illustrate the input that the user is typing in -- obviously the underlining
will not appear on the console.
- You may assume that user input will be correct (i.e. numeric entries
and valid dimensions)
General Requirements
- No global variables
- All input and output must be done with streams, using the library
iostream
- You may only use the iostream library (you do not need
any others for these tasks)
- When you write source code, it should be readable and
well-documented.
Style Guidelines for Programs
A sample run: (user input underlined)
Welcome to Paint Calculator 2023!!
How wide is the wall (in feet)? 40
and how high is the wall to the bottom of the roof? 15.7
and how high is the wall to the top of the roof? 21.5
How wide is the window (in feet)? 3
and what is the window's height? 2.75
A side wall that is
40' wide and
15.7' tall to the roof bottom and
21.5' tall to the roof top,
containing a window that is
3' wide and
2.75' tall,
has 735.8 square feet of paintable wall
and would require 1.84 cans of paint
(assuming that each can will cover 400 square feet of wall).
Thanks for using Paint Calculator 2023. Goodbye!!
Compiling and Running:
This code only uses a standard library (iostream), so it will compile
with any C++ compiler. Make sure you practice with g++ on linprog.cs.fsu.edu
(and make sure it reports no compile errors!) before you submit the program.
To compile with g++ (reminder)
Save a program file in your CS account space (on linprog.cs.fsu.edu)
and compile it with the g++ command:
g++ paint.cpp
The default name for the executable will be "a.out". To run it, type:
a.out
If you wish to compile the executable program to have a different name
(other than a.out), use the -o option on the g++ command. This allows you
to name your executable -- the executable name goes after the "-o".
Example:
g++ paint.cpp -o paint (executable name will be "paint")
Submitting:
Make sure you are logged into either
shell.cs.fsu.edu or linprog.cs.fsu.edu, and the
file you want to submit is stored in your current working directory.
To submit, type the following command:
~myers/csub/submit1 paint.cpp
(noting that the filename for your code should be paint.cpp ).
This will run a script and a C++ program that copies your file into a
submission directory. The program will also give you feedback at the end
-- it will display the contents of the file you just submitted to standard
output. This will allow you to check to make sure that what you submitted
was correct.
General Advice - always keep an untouched copy of your finished
homework files on your computer science account. These files will have a
time-stamp which will show when they were last worked on (a timestamp from
the CS servers) and will serve as a backup in case you ever have
legitimate problems with submitting files through the web site.
Do this for ALL programs.
It is a good idea as well to back up your file(s) by
transferring a copy (via SFTP) to your personal computer periodically
while you are working on an assignment. This way, if you accidentally
delete an important file on your CS account, you'll have a backup on
your computer.