Newbie! Help With Two Simple C++ Programs.

This is a discussion on Newbie! Help With Two Simple C++ Programs. within the C++ Programming forums, part of the General Programming Boards category; Well I have these two C++ programs that I have write for my class and I was wondering I you ...

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

    Newbie! Help With Two Simple C++ Programs.

    Well I have these two C++ programs that I have write for my class and I was wondering I you guys could help me out.
    I AM NOT ASK YOU TO DO MY HOMEWORK! I JUST WANT TO KNOW HOW TO FIGURE OUT THE MATHEMATICAL EQUATIONS.
    Here are the problems:

    Problem 1.A cereal Company wants to know how many Trailer Containers needs to use to transport itís cereal to a City. They want to create a program that will calculate this amount. The data is as follows:

    The number of Cereal boxes is variable
    They know that 20 Cereal boxes fit into a cardboard box.
    And they know that 3000 cardboard boxes fit into a Trailer Container.

    For a given number of Cereal boxes calculate the number of cardboard boxes and the number of Trailer Containers they need to rent to transport them.

    Using cin, cout and integer variables write a program that asks the user how many Cereal boxes they want to transport and gives as a result the number of Cardboard Boxes and Trailer Containers to rent.

    Problem 2. Using cin, cout and float variables write a program to solve the following problem: four friends buy a pizza that costs $20.00. Each person contributes with the following amount of money.

    Jane $5.00
    Mike $8.00
    Mary $3.00
    Joe $4.00

    Each person will eat the amount of pizza proportional to the amount of money they paid. Write a program that reports how much pizza (percentage) each person can eat.


    Thank You Guys So Much In Advanced!

  2. #2
    Information Crocodile
    Join Date
    Dec 2004
    Posts
    204
    Ill help you with the first one since it looks easier. I hope i got the problem right.

    Code:
    #include<iostream.h>
    #include<stdlib.h>
    
    using namespace::std;
    
    int getNeeded( int iVar, int iMax );
    
    int main()
    {
          int iCerials = 0;
          int iBoxes   = 0;
          int iTrucks  = 0;
    
          cout << "Number of Cerial boxes ? ";
          cin >> iCerials;
    
          iBoxes = getNeeded( iCerials, 20 );
          iTrucks = getNeeded( iBoxes, 3000 );
    
          cout << "Needed CardBoard Boxes is " << iBoxes;
          cout << "\nNeeded Trailers is " << iTrucks;
    
          return 0;
    }
    
    int getNeeded( int iVar, int iMax )
    {
        int iret = 1;
    
        while( iVar > iMax ){
               iVar -= iMax;
               iret++;
        }
    
        return iret;
    }

  3. #3
    Information Crocodile
    Join Date
    Dec 2004
    Posts
    204
    I just made the second one. But ill leave it for you to solve. I dont want to teach you laziness .

    You just need to know how to calculate the percentage and you can solve this problem.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    > I AM NOT ASK YOU TO DO MY HOMEWORK!
    So what are you asking - how to do high-school maths?

    I mean, once you've got past the cin and cout, what else is there to do?

    And next time you say "I don't want people to...", start by posting what you've achieved so far, because to be honest these problems are too damn simple that it's hard NOT to do the whole thing for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    21
    Thanks a lot loko! I really appreciate you helping me out!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Starting programs
    By Molokai in forum C Programming
    Replies: 1
    Last Post: 04-16-2009, 10:10 AM
  2. the holy grail for newbie programmers...
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 10-08-2003, 07:19 PM
  3. Replies: 8
    Last Post: 11-20-2001, 11:13 PM
  4. Replies: 3
    Last Post: 11-04-2001, 02:53 PM
  5. Need help with simple programs...
    By BCole19 in forum C++ Programming
    Replies: 22
    Last Post: 08-30-2001, 09:45 PM

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