Re: This is homework but I need advice please



 DEVELOP > c-Plus-Plus > Re: This is homework but I need advice please

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "nadz"
Date: 15 Oct 2003 10:20:46 PM
Object: Re: This is homework but I need advice please
I don't think of myself has a expert programmer and am a student just like
you only maybe a little farther along. But my recommendation would be to
work it out into two seperate variables one containing the whole number and
the other the decimal part. I had to do a similar assingment and the
biggest advice I can give you is take advantage of the mod operator. I hope
that helps.
~Justin
"minndream" <member42700@dbforums.com> wrote in message
news:3405816.1065316089@dbforums.com...


this is homework and I do not want an answer but if somebody could give
me a little nudge in the right direction I would be very grateful.



This is what I am supposed to do:



Write a program that promps for and reads a floating-point value. The
program prints the whole part on one line and the decimal part on the
second line example: 23.45



23

45



This is what I have so far:



#include <iostream>

#include <string>

using namespace std;

int main(){



float a = 0;

double b = 0;





cout<<"Enter a 4 digit number example 23.45: "<< endl;

cin>>a>>b;





cout<<a<<"\n."<<b<< endl;



return 0;

}



again, I don't want the answer but I am missing something.



Thanks so much!!!


--
Posted via http://dbforums.com

.

User: "Xenos"

Title: Re: This is homework but I need advice please 16 Oct 2003 04:12:29 PM
"nadz" <jnadz@lsol.net> wrote in message
news:vos3lu4rt2buc2@corp.supernews.com...

I don't think of myself has a expert programmer and am a student just like
you only maybe a little farther along. But my recommendation would be to
work it out into two seperate variables one containing the whole number

and

the other the decimal part. I had to do a similar assingment and the
biggest advice I can give you is take advantage of the mod operator. I

hope

that helps.

~Justin
"minndream" <member42700@dbforums.com> wrote in message
news:3405816.1065316089@dbforums.com...


this is homework and I do not want an answer but if somebody could give
me a little nudge in the right direction I would be very grateful.



This is what I am supposed to do:



Write a program that promps for and reads a floating-point value. The
program prints the whole part on one line and the decimal part on the
second line example: 23.45

Don't do anything complicated and don't mod, cast, etc. Look up the floor
function and think about what this will give you: f1 = floor(f); f2 = f -
f1; Now what is the values in f1 and f2, if f the the original value?
DrX
.

User: "osmium"

Title: Re: This is homework but I need advice please 16 Oct 2003 09:49:52 AM
nadz writes:

I don't think of myself has a expert programmer and am a student just like
you only maybe a little farther along. But my recommendation would be to
work it out into two seperate variables one containing the whole number

and

the other the decimal part. I had to do a similar assingment and the
biggest advice I can give you is take advantage of the mod operator. I

hope

that helps.

~Justin
"minndream" <member42700@dbforums.com> wrote in message
news:3405816.1065316089@dbforums.com...


this is homework and I do not want an answer but if somebody could give
me a little nudge in the right direction I would be very grateful.



This is what I am supposed to do:



Write a program that promps for and reads a floating-point value. The
program prints the whole part on one line and the decimal part on the
second line example: 23.45

I haven't been following this thread but I don't think the hint is a really
good one since the modulo operator operates on _integers_. New hint:
browse around in <cmath>.
.

User: "Andrew Heath"

Title: Re: This is homework but I need advice please 16 Oct 2003 09:16:29 PM
nadz wrote:

I don't think of myself has a expert programmer and am a student just like
you only maybe a little farther along. But my recommendation would be to
work it out into two seperate variables one containing the whole number and
the other the decimal part. I had to do a similar assingment and the
biggest advice I can give you is take advantage of the mod operator. I hope
that helps.

~Justin
"minndream" <member42700@dbforums.com> wrote in message
news:3405816.1065316089@dbforums.com...

this is homework and I do not want an answer but if somebody could give
me a little nudge in the right direction I would be very grateful.



This is what I am supposed to do:



Write a program that promps for and reads a floating-point value. The
program prints the whole part on one line and the decimal part on the
second line example: 23.45



23

45



This is what I have so far:



#include <iostream>

#include <string>

using namespace std;

int main(){



float a = 0;

double b = 0;





cout<<"Enter a 4 digit number example 23.45: "<< endl;

cin>>a>>b;





cout<<a<<"\n."<<b<< endl;



return 0;

}



again, I don't want the answer but I am missing something.



Thanks so much!!!


--
Posted via http://dbforums.com




Another suggestion - the program requirements you have given do not
explicitly state "you must use a float or double variable". So all you
might have to deal with is two integers seperated by a '.' or even two
strings.
.
User: "Joe"

Title: Re: This is homework but I need advice please 18 Oct 2003 06:19:26 PM
IMHO it is worth looking at formatting a string and using that only for
output. Think of the functionality of sprintf().
"Andrew Heath" <andrew.heath@studentmail.newcastle.edu.au> wrote in message
news:3F8F5158.9000909@studentmail.newcastle.edu.au...

nadz wrote:

I don't think of myself has a expert programmer and am a student just

like

you only maybe a little farther along. But my recommendation would be

to

work it out into two seperate variables one containing the whole number

and

the other the decimal part. I had to do a similar assingment and the
biggest advice I can give you is take advantage of the mod operator. I

hope

that helps.

~Justin
"minndream" <member42700@dbforums.com> wrote in message
news:3405816.1065316089@dbforums.com...

this is homework and I do not want an answer but if somebody could give
me a little nudge in the right direction I would be very grateful.



This is what I am supposed to do:



Write a program that promps for and reads a floating-point value. The
program prints the whole part on one line and the decimal part on the
second line example: 23.45



23

45



This is what I have so far:



#include <iostream>

#include <string>

using namespace std;

int main(){



float a = 0;

double b = 0;





cout<<"Enter a 4 digit number example 23.45: "<< endl;

cin>>a>>b;





cout<<a<<"\n."<<b<< endl;



return 0;

}



again, I don't want the answer but I am missing something.



Thanks so much!!!


--
Posted via http://dbforums.com





Another suggestion - the program requirements you have given do not
explicitly state "you must use a float or double variable". So all you
might have to deal with is two integers seperated by a '.' or even two
strings.

.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER