C++ math equation

This is a discussion on C++ math equation within the C++ Programming forums, part of the General Programming Boards category; So the get the area of the largest circle I can use the shortest side of the rectangular piece for ...

  1. #16
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    So the get the area of the largest circle I can use the shortest side of the rectangular piece for the circle equation.

    A= Pi * r^2 r being the shortest side / 2. If I get this right.

  2. #17
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Looks correct to me.

  3. #18
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    I would use If to get the shortest side. Is there an easier short way?

    Well, actually If I use length and width... width would be the shortest side.
    Last edited by XodoX; 03-01-2009 at 08:44 PM.

  4. #19
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Try writing the whole program by yourself, using the methods you know. Post back if you have any problems or are getting errors you don't understand.

    Most likely, many methods used by some of the programmers here are beyond you and wouldn't be accepted by your prof. So use what you know and let us know if you hit a road block.

  5. #20
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Well, like I said.. I will use the length ( not width, sorry) as my shortest side.

  6. #21
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Ok ,this is what I have now. We also had to convert it to acre. That's why I divided it.

    Code:
    // Headers and Other Technical Items
    
    #include <iostream>
    using namespace std;
    
    // Function Prototypes
    
    void get_data(void);
    void process_data(void);
    void show_results(void);
    void pause(void);
    
    // Variables
    
    
    double  length;
    double  width;
    double total_rectangular;
    float pi;
    float farmable_area;
    float nonfarmable;
    
    //******************************************************
    // main
    //******************************************************
    
    int main(void)
      {
      get_data();
      process_data();
      show_results();
    
      return 0;
      }
      // Input 
      
      void get_data(void)
      {
    
      cout << "\nEnter the length of the property in feet --->: ";
      cin >> length;
      cout << "\nEnter the width of the property in feet ---->: ";
      cin >> width;
      
    return;
      }
      // Process
    
    
    void process_data(void)
      {
      pi = 3.14159265;
      total_rectangular = (length * width)/ 43560;
      
      farmable_area=pi*(width/2)*(width/2)/43560;
      
      nonfarmable = total_rectangular - farmable_area/43560;
      
      
      
      return;
      }
    
    
    
      // Output - 
    
    
    void show_results(void)
      {
      cout << "\n";
      cout << "\nThe total area of the property is ---->: ";
      cout << total_rectangular;
      cout << "\nThe total area that is farmable is ---->: ";
      cout << farmable_area;
      
      pause();
      return;
      }
    
      
      
    
    //******************************************************
    // pause
    //******************************************************
    
    void pause(void)
      {
      cout << "\n\n";
      system("PAUSE");
      cout << "\n\n";
      return;
      }

  7. #22
    Registered User
    Join Date
    Feb 2009
    Posts
    37
    Where does this number 43560 come from? Oh it's an acre, I see.
    However, the unfarmable area is already in acres.

    Also I would not assume that width is smaller, you probably should check and use whichever value is smaller. Or at least make it clear to the user that they need to type the smaller value into width.
    Last edited by rossipoo; 03-01-2009 at 11:15 PM.

  8. #23
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Thank you for the hint!

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

Similar Threads

  1. Replies: 15
    Last Post: 11-04-2006, 04:06 AM
  2. Converting String to Math Equation
    By draggy in forum C++ Programming
    Replies: 5
    Last Post: 07-10-2005, 07:59 PM
  3. Math Equation Program (I can't find the problem with my program!)
    By masked_blueberr in forum C Programming
    Replies: 14
    Last Post: 07-06-2005, 12:53 PM
  4. IDEA: Equation solver
    By Magos in forum Contests Board
    Replies: 2
    Last Post: 01-07-2003, 11:46 AM
  5. A math equation
    By dizolve in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-17-2002, 12:56 PM

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