View Single Post
Old 02-05-2007, 03:17 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,720
redhead is on a distinguished road
Quote:
your coding is right but is too advanced from what we are learning right now
Then give some advice to what level you're at right now..
At the moment I assume you know of the cout/cin streams, and how you can use them..

The iomanip part, is just to make sure the result will be nicely displayed with two decimals showing even if the result should be 34221.89237 it will only show 34221.89 Which would make it more appropriate to say, "the price is $34.80" instead of something like "the price is $34.804221"

The while() loop which is surrounding the initial diameter reading, is a way to make sure the user is forced to input a positive value, since you can't have a negative diameter of any circle no matter how hard you try (4.th dimensions not enclosed)

The use of the word const is to make sure the pi value can never be changed..

Oh and by the way, the formular I'm refering to is the old Pi*diameter like any school kid should know by 4'th or 5'th grade if I remember correct..

If you want me to explain the code line by line, then just say so, and I'll give it my best.

If it's the cout.flush() that is throwing you off, then they are used to flush teh output stream, in order to make sure any charactor is displayed on teh screen befor accepting any input, since in teh previus lines I'm not using std::endl to flsuh teh stream.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote