Mail Archives: djgpp/2001/02/27/13:18:38
From: | "Brian Christiansen" <brianc23454 AT earthlink DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
References: | <XoBm6.206$GF DOT 50463 AT sapphire DOT mtt DOT net>
|
Subject: | Re: convert miles to kilometres
|
Lines: | 31
|
MIME-Version: | 1.0
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.50.4133.2400
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4133.2400
|
Message-ID: | <aERm6.1175$w4.159034@newsread2.prod.itd.earthlink.net>
|
Date: | Tue, 27 Feb 2001 17:40:22 GMT
|
NNTP-Posting-Host: | 63.23.230.117
|
X-Complaints-To: | abuse AT earthlink DOT net
|
X-Trace: | newsread2.prod.itd.earthlink.net 983295622 63.23.230.117 (Tue, 27 Feb 2001 09:40:22 PST)
|
NNTP-Posting-Date: | Tue, 27 Feb 2001 09:40:22 PST
|
Organization: | EarthLink Inc. -- http://www.EarthLink.net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
"Stewart" <jstewart1 AT ns DOT sympatico DOT ca> wrote in message
news:XoBm6.206$GF DOT 50463 AT sapphire DOT mtt DOT net...
> Can you help me write a C++ program that uses include <iostream.h> which
has
> a function to convert miles to kilometres.
Use #include <iostream> - this is the newer standard and if you have the
latest version of DJGPP, it certainly supports this form.
>( 1 km = 0.621371 miles I think)
> What const double can I use for the conversion factor?
0.621371 or its recipricol 1.6-whatever seems like a good idea to me. If
you mean what name to use, any legal C++ name will do, though it is probably
better to use something that is "meaningful", like maybe "miles_to_km" (the
compiler itself doesn't care if you call it "fred".
> In more particular terms, I need help to write a program that prompts the
> user for a value in miles and outputs the equivalent value in km using a
> precision of 2 digits after the decimal.
To ouput other than the default number of decimal places, #include <iomanip>
and read up on the functions provided therein.
Can anyone help me?
I am sure there are plenty of people who can, probably even I could, but
since this sounds a whole lot like a homework assignment, attempt writing
this program, post the code, and I am sure that some nice peron will help
you fix it.
Brian Christiansen>
>
- Raw text -