1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yarga [219]
3 years ago
7

C++ - Green Crud Fibonacci programThe following program is to be written with a loop. You are to write this program three times

and each time with a different loop control structure (for loop, while and do-while).The Fibonacci numbers Fn are define as follows. F0 is 1, F1 is 1, and Fi+2 = Fi + Fi+1 for i = 0, 1, 2, 3, ... In other words, each number is the sum of the previous two integer numbers. The first few Fibonacci numbers are 1, 1, 2, 3, 5, and 8. One place that these numbers occur is as certain population growth rates. If a population has no deaths, then the series shows the size of the population after each time period. It takes an organism two time periods to mature to reproducing age, and then the organism reproduces once every time period (thus the reason for two 1's before you start adding). The formula applies most straightforwardly to a sexual reproduction at a rate of one offspring per time period.Assume that the green crud population grows at this rate and has a time period of 10 days. Hence, if a green crud population starts out as 5 pounds of crud, then in 10 days there is still 5 pounds of crud; at the end of the next 10 days there is 10 pounds of crud; in 20 days 10 pounds (the sum of the previous two 10 day periods). Write a program that takes both the initial size of green crud population (in pounds) and a number of days as input, and output the number of pounds of green crud after that many days of growth. Assume that the population size is the same for 9 days and then increases every tenth day.Input to the crud program: start with 5 pounds of green crude and display the how much crude we have after 200 days. Run each of the three versions of the program with 200 days. You can NOT use arrays for this program.Now, what happens when you run the program for 225 days when you use the simple data type ‘int’? (Not long int or double ect.)
Engineering
1 answer:
Fynjy0 [20]3 years ago
7 0

Answer:

Below is the required code:

Explanation:

Using for loop

#include <iostream>

using namespace std;

int main()

{

    //Initial crud size

    int init = 0;

    int newCrud;

    int next=0;

    //Number of days to simulate

    int no_days;

    int day;

    cout << "Enter initial amount of green crud: ";

    cin >> newCrud;

    cout << "Enter number of days to simulate: ";

    cin >> no_days;

    for (day = 10; day<=no_days; day++)

    {

         if (day % 10 == 0)

         {

             next = newCrud + init;

         }

             newCrud = init;

             init = next;

    }

    if (no_days < 5)

    cout << "\nCrud reproduce only after 5 days minimum.Hence the current amount is "

    << newCrud << " pounds.";

    else

    cout << "On day " << no_days << " you have " << init

    << " pounds of green crud." << endl;

    cout << "\nWould you like to continue? (y or n): ";

    cin >> ans;

         return 0;

}

Output:

         Enter initial amount of green crud: 5

         Enter number of days to simulate: 220

    On day 220 you have 10485760 pounds of green crud.

Using while loop

Program:

#include <iostream>

using namespace std;

int main()

{

    char ans='y';

    while (ans == 'Y' || ans == 'y')

    {

         //Initial crud size

         int init = 0;

         int newCrud;

         int next=0;

         //Number of days to simulate

         int no_days;

         int day;

         cout << "Enter initial amount of green crud:

         ";

         cin >> newCrud;

         cout << "Enter number of days to simulate:

         ";

         cin >> no_days;

         for (day = 10; day<=no_days; day++)

         {

             if (day % 10 == 0)

             {

                  next = newCrud + init;

             }

                  newCrud = init;

                  init = next;

         }

         if (no_days < 5)

         cout << "\nCrud reproduce only after 5 days

         minimum.Hence the current amount is "

         << newCrud << " pounds.";

         else

         cout << "On day " << no_days << " you have "

         << init

         << " pounds of green crud." << endl;

         cout << "\nWould you like to continue? (y or

         n): ";

         cin >> ans;

    }

    return 0;

}

Output:

Enter initial amount of green crud: 5

Enter number of days to simulate: 220

On day 220 you have 10485760 pounds of green crud.

Would you like to continue? (y or n): y

Enter initial amount of green crud: 5

Enter number of days to simulate: 225

On day 225 you have 10485760 pounds of green crud.

Using do while loop

Program:

#include <iostream>

using namespace std;

int main()

{

    char ans;

    do

    {

         //Initial crud size

         int init = 0;

         int newCrud;

         int next=0;

         //Number of days to simulate

         int no_days;

         int day;

         cout << "Enter initial amount of green crud: ";

         cin >> newCrud;

         cout << "Enter number of days to simulate: ";

         cin >> no_days;

         for (day = 10; day<=no_days; day++)

         {

             if (day % 10 == 0)

             {

                  next = newCrud + init;

             }

                  newCrud = init;

                  init = next;

         }

         if (no_days < 5)

         cout << "\nCrud reproduce only after 5 days

         minimum.Hence the current amount is "

         << newCrud << " pounds.";

         else

         

         cout << "On day " << no_days << " you have " <<

         init << " pounds of green crud." << endl;

         cout << "\nWould you like to continue? (y or n):

         ";

         cin >> ans;

    } while (ans == 'Y' || ans == 'y');

    return 0;

}

Output:

Enter initial amount of green crud: 5

Enter number of days to simulate: 220

On day 220 you have 10485760 pounds of green crud.

Would you like to continue? (y or n): y

Enter initial amount of green crud: 5

Enter number of days to simulate: 225

On day 225 you have 10485760 pounds of green crud.

You might be interested in
Which type of system is being researched to deliver power to several motors to drive multiple systems in vehicles?
qaws [65]

Answer:

pneumatic power system

Explanation:

pneumatic power can be used to quietly operate power windows, door locks, power mirrors, and much much more, also negative pressure pneumatics (vacuum) is used to control many engine and fuel systems

8 0
2 years ago
Air at 38°C and 97% relative humidity is to be cooled to 14°C and fed into a plant area at a rate of 510m3/min. (a) Calculate th
Katarina [22]

To develop the problem it is necessary to apply the concepts related to the ideal gas law, mass flow rate and total enthalpy.

The gas ideal law is given as,

PV=mRT

Where,

P = Pressure

V = Volume

m = mass

R = Gas Constant

T = Temperature

Our data are given by

T_1 = 38\°C

T_2 = 14\°C

\eta = 97\%

\dot{v} = 510m^3/kg

Note that the pressure to 38°C is 0.06626 bar

PART A) Using the ideal gas equation to calculate the mass flow,

PV = mRT

\dot{m} = \frac{PV}{RT}

\dot{m} = \frac{0.6626*10^{5}*510}{287*311}

\dot{m} = 37.85kg/min

Therfore the mass flow rate at which water condenses, then

\eta = \frac{\dot{m_v}}{\dot{m}}

Re-arrange to find \dot{m_v}

\dot{m_v} = \eta*\dot{m}

\dot{m_v} = 0.97*37.85

\dot{m_v} = 36.72 kg/min

PART B) Enthalpy is given by definition as,

H= H_a +H_v

Where,

H_a= Enthalpy of dry air

H_v= Enthalpy of water vapor

Replacing with our values we have that

H=m*0.0291(38-25)+2500m_v

H = 37.85*0.0291(38-25)-2500*36.72

H = 91814.318kJ/min

In the conversion system 1 ton is equal to 210kJ / min

H = 91814.318kJ/min(\frac{1ton}{210kJ/min})

H = 437.2tons

The cooling requeriment in tons of cooling is 437.2.

3 0
3 years ago
Suppose you are asked to design an office building. Explain what type of drawing you would use and why.
ohaa [14]

Answer:

birds-eye view perspective

Explanation:

If someone asked me to design an office building, I would draw it from a birds-eye view perspective. I would draw it this way so I could map out where everything in the office would go and make sure I have enough space for everything. I would also draw it this way in order to clearly see where everything would go in the office. For instance, cubicles/desks could go in the bottom left corner, while the boss's office could go in the top right. It would be easier to organize and it would be easier for me to look back on when I need to actually design the office later.

(i'm not sure if this is what your question is asking for so i just made my best guess)

7 0
3 years ago
Read 2 more answers
____ grinders are used to grind diameters, shoulders, and faces much like the lathe is used for turning, facing, and boring oper
skelet666 [1.2K]

Answer:

Cylindrical

Explanation:

<em>A cylindrical grinder </em><em>is a tool for shaping the exterior of an item. Although cylindrical grinders may produce a wide range of forms, the item must have a central axis of rotation. Shapes such as cylinders, ellipses, cams, and crankshafts are examples of this.</em><em> Cylindrical grinding</em><em> machines are specialized grinding machines that are used to process cylinders, rods, and similar workpieces. The cylinders revolve in one direction between two centers, while the grinding wheel or wheels are close together and rotate in the other direction.</em>

8 0
2 years ago
Another focus of effective communication, according to Stephen Covey, is ensuring that:
svetoff [14.1K]

Answer:

Stephen Covey believes this principle is the key to effective interpersonal communication. Seek first to understand, then to be understood. This habit is about communicating with others. It's about developing the habit of listening carefully and really understanding the other person BEFORE giving your thoughts.

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • A cylinder contains 480 cm3 of loose dry sand which weighs 820 g. Under a static load of 200 kPa the volume is reduced 1%, and t
    15·1 answer
  • 100 points Im so bored lol
    11·2 answers
  • Hey, can anyone tell me if Igneous rock is good to build on? Cheers!
    6·1 answer
  • Someone claims that the shear stress at the center of a circular pipe during fully developed laminar flow is zero. Do you agree
    12·1 answer
  • QUESTIONS
    12·1 answer
  • Which type of load is not resisted by a pinned joint? A) Moment B) Shear C) Axial D) Compression
    7·1 answer
  • The information on a can of pop indicates that the can contains 360 mL. The mass of a full can of pop is 0.369 kg, while an empt
    14·1 answer
  • What are the main causes of injuries when using forklifts?
    5·1 answer
  • a motor has torque of 200 nm if i motors attached to an arm with a length of 25 cm and a string is too attached to the end appro
    13·1 answer
  • A ____ is either in the pressure reducer or in the downstream side of the system to ensure that the control air pressure does no
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!