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
A steel plate has a hole drilled through it. The plate is put into a furnace and heated. What happens to the size of the inside
djverab [1.8K]

Answer:

The diameter increases

Explanation:

The expansion in the metal is uniform in every dimension

4 0
3 years ago
What are the disadvantages of having a liquid cooled engine?
Feliz [49]
One notable disadvantage of liquid cooling over air cooling is that it is considerably costly to set up. Cooling fans are prevalent in the market, and this overabundance of supply means they are cheap. The components of a liquid cooling system can be expensive.
5 0
3 years ago
The roof of a refrigerated truck compartment consists of a layer of foamed urethane insulation (t2 = 21 mm, ki = 0.026 W/m K) be
lakkis [162]

Answer:

Tso = 28.15°C

Explanation:

given data

t2 = 21 mm

ki = 0.026 W/m K

t1 = 9 mm

kp = 180 W/m K

length of the roof is L = 13 m

net solar radiation into the roof = 107 W/m²

temperature of the inner surface Ts,i = -4°C

air temperature is T[infinity] = 29°C

convective heat transfer coefficient h = 47 W/m² K

solution

As when energy on the outer surface at roof of a refrigerated truck that is balance as

Q = \frac{T \infty - T si }{\frac{1}{hA}+\frac{t1}{AKp}+\frac{t2}{AKi}+\frac{t1}{aKp}}       .....................1

Q = \frac{T \infty - Tso}{\frac{1}{hA}}                         .....................2

now we compare both equation 1 and 2 and put here value

\frac{29-(-4)}{\frac{1}{47}+\frac{2\times0.009}{180}+\frac{0.021}{0.026}} = \frac{29-Tso}{\frac{1}{47}}            

solve it and we get

Tso = 28.153113

so Tso = 28.15°C

3 0
3 years ago
A cold air standard gas turbine engine with a thermal efficiency of 56.9 % has a minimum pressure of 100 kP
Aleks04 [339]

Answer:

a) 5.2 kPa

b) 49.3%

Explanation:

Given data:

Thermal efficiency ( л ) = 56.9% = 0.569

minimum pressure ( P1 ) = 100 kpa

<u>a) Determine the pressure at inlet to expansion process</u>

P2 = ?

r = 1.4

efficiency = 1 - [ 1 / (rp)\frac{r-1}{r} ]

   0.569   = 1 - [ 1 / (rp)^0.4/1.4

1 - 0.569  = 1 / (rp)^0.285

∴ (rp)^0.285 = 0.431

rp = 0.0522

note : rp = P2 / P1

therefore P2 = rp * P1 = 0.0522 * 100 kpa

                                   = 5.2 kPa  

b) Thermal efficiency

Л = 1 - [ 1 / ( 10.9 )^0.285 ]

   = 0.493 = 49.3%

4 0
3 years ago
Convert 850 nm wavelength into frequency, eV, wavenumber, joules and ergs.
Sholpan [36]

Answer:

Frequency = 3.5294\times 10^{14}s^{-1}

Wavenumber = 1.1765\times 10^6m^{-1}

Energy = 2.3365\times 10^{-19}J

Energy = 1.4579 eV

Energy = 2.3365\times 10^{-12}erg

Explanation:

As we are given the wavelength = 850 nm

conversion used : (1nm=10^{-9}m)

So, wavelength is  850\times 10^{-9}m

The relation between frequency and wavelength is shown below as:

Frequency=\frac{c}{Wavelength}

Where, c is the speed of light having value = 3\times 10^8m/s

So, Frequency is:

Frequency=\frac{3\times 10^8m/s}{850\times 10^{-9}m}

Frequency=3.5294\times 10^{14}s^{-1}

Wavenumber is the reciprocal of wavelength.  

So,  

Wavenumber=\frac{1}{Wavelength}=\frac{1}{850\times 10^{-9}m}

Wavenumber=1.1765\times 10^6m^{-1}

Also,  

Energy=h\times frequency

where, h is Plank's constant having value as 6.62\times 10^{-34}J.s

So,  

Energy=(6.62\times 10^{-34}J.s)\times (3.5294\times 10^{14}s^{-1})

Energy=2.3365\times 10^{-19}J

Also,  

1J=6.24\times 10^{18}eV

So,  

Energy=(2.3365\times 10^{-19})\times (6.24\times 10^{18}eV)

Energy=1.4579eV

Also,  

1J=10^7erg

So,  

Energy=(2.3365\times 10^{-19})\times 10^7erg

Energy=2.3365\times 10^{-12}erg

5 0
3 years ago
Other questions:
  • The uniform dresser has a weight of 90 lb and rests on a tile floor for which the coefficient of static friction is 0.25. If the
    6·1 answer
  • How much heat (Btu) is prod uced by a 150-W light bulb that is on for 20-hours?
    14·1 answer
  • An inventor claims to have developed a power cycle operating between hot and cold reservoirs at 1175 K and 295 K, respectively,
    9·1 answer
  • Mining is an example of this type of business
    7·1 answer
  • Before turning in a test, it would be best to
    6·2 answers
  • 3. Sitúese en la época de los faraones en Egipto. Usted es el encargado de construir una de esas fabulosas pirámides que fueron
    11·1 answer
  • Draw the ipo chart for a program that reads a number from the user and display the square of that number ???Anyone please
    11·1 answer
  • You may wonder who the rest goes
    11·1 answer
  • Reason fo I.EE regulations in electrical installations​
    13·1 answer
  • Metal wireways are sheet metal troughs with _____________ for housing and protecting electrical conductors and cable.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!