Need Help ASAP....

This is a discussion on Need Help ASAP.... within the C++ Programming forums, part of the General Programming Boards category; I have tried for the past week to figure this problem out and I have no idea how to do ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    6

    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.

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Can we see what code you have or do you want us to write it all for you?

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    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

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    Code:
    #include <iostream.h>
    
    int main ()
    
    
    {
     
        int a;
        int b;
        int c;
        int d;
    
    
    
    
    	reurn 0;
    
    }
    I seriously have no idea what im doing

  5. #5
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    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.

    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.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Use four decimal places of precision for the floating point values.
    Code:
    printf("%.4f\n", floatname);
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    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).
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  8. #8
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by dwks
    Code:
    printf("%.4f\n", floatname);
    Thats C

    *hides* read my post for the C++ version.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  9. #9
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    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...

  10. #10
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    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;
    
    }

  11. #11
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    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).
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  12. #12
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    *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

  13. #13
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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.

  14. #14
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    Im sorry that i have A.D.D.

    Nobody is perfect.

  15. #15
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help ASAP ,
    By Haytham in forum C Programming
    Replies: 3
    Last Post: 05-14-2007, 11:21 AM
  2. Help Needed Please... Asap
    By Shabba in forum C Programming
    Replies: 2
    Last Post: 01-13-2004, 04:24 PM
  3. Strange characters in output Need Help ASAP
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2003, 06:35 PM
  4. Count_nums (need help ASAP!)
    By legacye in forum C Programming
    Replies: 6
    Last Post: 11-22-2003, 06:32 PM
  5. Help Needed Asap With Searching An Array!
    By HelpMe++ in forum C++ Programming
    Replies: 5
    Last Post: 05-23-2003, 05:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21