new to C++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2005
Posts: 17
Reputation: dal4488 is an unknown quantity at this point 
Solved Threads: 0
dal4488 dal4488 is offline Offline
Newbie Poster

new to C++

 
0
  #1
Feb 11th, 2005
Hi, I'm totally new to C++ and so far am extremely confused. I was wondering if anyone could give me any help with one of my assignments. Basically I don't know where to even start. I think if maybe someone can help me get started maybe I can figure this problem out. Anyways, here's the problem...

Write a program that prompts the user to input a length expressed in centimeters. The program should then convert the length to inches and output the length expressed in yards, feet, and inches, in that order. For example suppose the input for centimeters is 312. To the nearest inch, 312 centimeters is equal to 123 inches. 123 inches would thus be output as:
3 yards, 1 foot, and 3 inches.

Any help would be greatly appreciated.
Reply With Quote Quick reply to this message  
Join Date: May 2003
Posts: 307
Reputation: big_k105 is an unknown quantity at this point 
Solved Threads: 2
Team Colleague
big_k105's Avatar
big_k105 big_k105 is offline Offline
PFO Founder

Re: new to C++

 
0
  #2
Feb 11th, 2005
Well we dont do homework but here is a basic idea of how you would go about this. first you would need to ask the user to input the length in centimeters using cin. and then you take the info you get and you would then have the program convert centimeters to inches. and from inches its not hard to figure out how many yards, feet and inches that equals try to post atleast alittle bit of code next time thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 17
Reputation: dal4488 is an unknown quantity at this point 
Solved Threads: 0
dal4488 dal4488 is offline Offline
Newbie Poster

Re: new to C++

 
0
  #3
Feb 11th, 2005
Thanks for the help...Have I started this off right so far?

#include <iostream.h>

using namespace std;

const double conversion = 2.54
const int inchesPerFoot = 12

int main()
{
int centimeters, inches;
int yards, feet;

cout << "Enter length in centimeters: ";
cin >> centimeters;
cout << endl;
cout << "The number entered was " << centimeters
<< " for centimeters. " << endl;


return 0;
}
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,361
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 241
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: new to C++

 
0
  #4
Feb 12th, 2005
You need to terminate the following statements with semicolons:
const double conversion = 2.54;
const int inchesPerFoot = 12;
And this was okay many years ago...
  1. #include <iostream.h>
...but if you are living in the 21st century, it should be...
  1. #include <iostream>
...especially since you are...
  1. using namespace std;
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,019
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 931
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: new to C++

 
0
  #5
Feb 12th, 2005
Just a hint, after doing Dave's corrections study up on the modulus operator % ...
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC