# Need Help ASAP....

Printable View

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 09-14-2005
Maxwell
Need Help ASAP....
I have tried for the past week to figure this problem out and I have no idea how to do it. I need help with this ASAP. I have been working on this so long that I got headaches from it. ANY HELP WILL BE APPRECIATED!! THANK YOU.

Write a complete C++ program that demonstrates integer division and the modulus operator. Write a program objective to the screen and then ask the user to enter two integer values. Perform the division and modulus operations on these two numbers and assign the results into integers. Then repeat the operations and assign the results into float variables. Write the two values and four operation results to the screen. Use four decimal places of precision for the floating point values. Include descriptive comments.
• 09-14-2005
PJYelton
Can we see what code you have or do you want us to write it all for you?
• 09-14-2005
Tonto
I'm sure you could get the answer within 5 minutes looking at an informative resource. Check out cplusplus.com's Communication through the console portion of their tutorial, or the guidebook given with the course you are taking. I'm sure you will get something going. Also read the boards homework policy: http://cboard.cprogramming.com/annou...ouncementid=39
• 09-14-2005
Maxwell
Code:

``` #include <iostream.h> int main () {       int a;     int b;     int c;     int d;         reurn 0; }```
I seriously have no idea what im doing :(
• 09-14-2005
Enahs
Two numbers of type integer will result in only what is in front of the decimal place.

10/3 will result in just 3.
10%3 will result in the remainder or the numbers to the right of the decimal.

All you are doing is asking the user for two integers to divide.

You will the have to output the 10/3, manually output a ., then output the 10%3. (or whatever numbers the user inputs).

Then, with type float (or double) it is just outputting the 10/3 (which should be in type float or double).

Then just make your output all neat.

Quote:

Write the two values and four operation results to the screen.
I only count 3 operations. Division with integers (/), modulo (or however it is spelled)...the remainder (%), and normal division with type float.
• 09-14-2005
dwks
Quote:

Use four decimal places of precision for the floating point values.
Code:

`printf("%.4f\n", floatname);`
• 09-14-2005
Dae
Write a complete C++ program that demonstrates integer division and the modulus operator. Write a program objective to the screen and then ask the user to enter two integer values. Perform the division and modulus operations on these two numbers and assign the results into integers. Then repeat the operations and assign the results into float variables. Write the two values and four operation results to the screen. Use four decimal places of precision for the floating point values. Include descriptive comments.

modulus operator %
division operator /
assignment operator (assign something) =

- write something to screen: std::cout << "words here";

- cout is part of the <iostream> file

- ask the user to enter an integer values: std::cin >> a;

- write value to screen: std::cout << a;

- using precision when outputting using cout: std::cout << setprecision(4) << a;

Trying to do this for a week? I'm sure this wasn't just handed to you your first day, so you must have been sick/not paying attention/not there when instructions were given.. try doing the opposite. Try going over what the teacher has made you write down, showed you, or handed to you.. it should provide the information. As a backup you could have followed the first couple tutorials on this site, as they would give you the knowledge to complete this assignment (besides the modulus operator part).
• 09-14-2005
Dae
Quote:

Originally Posted by dwks
Code:

`printf("%.4f\n", floatname);`

Thats C :eek:

*hides* read my post for the C++ version.
• 09-14-2005
Maxwell
Quote:

Originally Posted by Dae
Trying to do this for a week? I'm sure this wasn't just handed to you your first day, so you must have been sick/not paying attention/not there when instructions were given..

Yeah...ive been in class for almost a month now and its kinda hard to retain the information when i have the class 2 days a week for 3 HOURS each day and NO BREAK.

Everyone kinda zones...
• 09-14-2005
Maxwell
Yeah i got so far....

Code:

``` #include <iostream.h> int main () {         int A;         int B;         int C;         int D;         cout<< "\n Please enter two Numbers: ";         cin>> A >> B;         cout<< "\n The result of the two numbers being divided is " << A/B << "\n"; return 0; }```
• 09-14-2005
Dae
Quote:

Originally Posted by Maxwell
Yeah...ive been in class for almost a month now and its kinda hard to retain the information when i have the class 2 days a week for 3 HOURS each day and NO BREAK.

Everyone kinda zones...

I would kill to have a programming course in my school, for 6 straight hours it'd be no problem to ace it and peer tutor.. too bad my school down right sucks (not enough people sign up for the classes to have them created).
• 09-14-2005
Enahs
*sigh*

Code:

```int main() {         int divisor;         int dividend;         int division_results;         int modulus_results;                 division_results = (dividend / divisor);         modulus_results = (dividend % divisor);         double quotient;         quotient =  (static_cast<double>(dividend)/divisor);                 return 0; }```

That will do everything you said (if I read it correctly).
You must do the input and output, as well as the decimal precision.

http://www.cprogramming.com/referenc...taticcast.html
http://www.cprogramming.com/tutorial/modulus.html
http://www.cprogramming.com/tutorial/lesson1.html

You might find this very very helpful:
http://www.ucc.vt.edu/stdysk/stdyhlp.html
• 09-14-2005
sean
Quote:

Yeah...ive been in class for almost a month now and its kinda hard to retain the information when i have the class 2 days a week for 3 HOURS each day and NO BREAK.
That's actually quite pathetic. If you can't focus for that long, you need to be getting more sleep. If you can't retain information, review it between classes. Don't come on the board and expect us to do your work for you. It's rude, and also against forum policies.
• 09-14-2005
Maxwell
Im sorry that i have A.D.D.

Nobody is perfect.
• 09-14-2005
sean
ADD may make it tough to learn, but it's by no means an excuse to have others do your work for you. Plagiarism is a serious offence at every institution of education that I've heard of.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last