4 Replies - 224 Views - Last Post: 09 October 2012 - 07:22 AM Rate Topic: -----

#1 kylin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-October 12

Stuck on this question ! Please HELP

Posted 09 October 2012 - 06:56 AM

I just get into C++ class
Write an entire program that will ask the user for their favorite decimal number. Print the number without the decimal point.

I got my code done so far but it not appeared that im going right.
using namespace std;

int main ()
{

//Input variables
double FAV_DECIMAL;


//Prompt the user for input
cout << " Enter your favorite decimal number: ";
cin >> FAV_DECIMAL;


cout << fixed << showpoint<< setprecision(3) << "FAV_DECIMAL = " << FAV_DECIMAL
<< endl;

system("PAUSE");
return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Stuck on this question ! Please HELP

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6035
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: Stuck on this question ! Please HELP

Posted 09 October 2012 - 06:58 AM

Quote

I got my code done so far but it not appeared that im going right.


Yeah, ya see...this has no meaning to us. Be specific as to

1. any errors you're receiving
2. input you're providing
3. output you're receiving, and what you expect the output to be for the input provided.
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is online

  • Dic Head
  • member icon

Reputation: 5167
  • View blog
  • Posts: 26,849
  • Joined: 10-May 07

Re: Stuck on this question ! Please HELP

Posted 09 October 2012 - 07:02 AM

This is a coding support forum. Generally questions are asked because someone is stuck & needs help. Therefor naming your topic "Stuck On This Question ! Please HELP" doesn't really give details for those whom may know the issue to click on the topic to offer their support. Please give meaningful names to topics when posting.
Was This Post Helpful? 0
  • +
  • -

#4 kylin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-October 12

Re: Stuck on this question ! Please HELP

Posted 09 October 2012 - 07:04 AM

So if I had the double value 919545.634521, it is always printed with the decimal places added to it. How can I print it without it so it looks like: 919545634521?
Was This Post Helpful? 0
  • +
  • -

#5 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1621
  • View blog
  • Posts: 3,079
  • Joined: 30-May 10

Re: Stuck on this question ! Please HELP

Posted 09 October 2012 - 07:22 AM

- read it as a string to begin with, then remove the dot before printing it.
- read it as a double, format it into a string, then remove the dot before printing it.

Try both, as an exercise.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1