Question

In: Computer Science

In C programming language, After studying gross annual revenues of Broadway shows over a 20-year period,...

In C programming language,

After studying gross annual revenues of Broadway shows over a 20-year period, you model the revenue as a function of time:

        R(t) = 203.265 X (1.071)^t, where R is in millions of dollars and t is the years since 1984. Create the following functions to implement this model:

        revenue - calculates R given the input parameter t. R is an output parameter.

        predict - predicts the year in which revenues (in millions) will first equal or exceed the value of the input parameter. For example, predict(200) would return 1984. The year should be returned through an output parameter.

Write a main () function that calls predict () to determine when revenues will likely exceed $1 trillion. Then create an output file that contains a table of estimated revenues for all the year from 1984 through the year when revenues should exceed $1 trillion.

Solutions

Expert Solution

Code for your program is provided below. Code is explained in the code comments. I have attached the screenshot of code in IDE, you can refer to the screenshot for your better understanding. Screenshot of output is provided in the last. If you need any further clarification please feel free to ask in comments. I would really appreciate if you let me know if the answer is upto your satisfaction or not.

#####################################################################

CODE

#include <stdio.h>    //including for standard input output
#include <stddef.h>   //including for using NULL
#include <stdlib.h>     //including for using exit()

//function declarations
double revenue(int);
int predict(double);

//main function
int main()
{
    //creating a pointer of FILE type
    FILE *outputFile;
    //Opening the file in "write" mode
    outputFile=fopen("output.txt","w");
    double money;   //variable to hold the revenue
    
    //if file is not opened or not created
    if(outputFile==NULL)
    {
        //print descriptive message on screen
        printf("Error occured while creating file. Press any key to Close the program.");
        getchar();   //hold the screen until a character is entered by user
        exit(0);  //exit the program
    }

    //cal predict method and store returned year in the variable
    int year=predict(1000000);  //1 trillion has 1000000 millions

    //for each year until the year when revenue is 1 trillion
    for(int t=1984;t<=year;t++)
    {
        money=revenue(t-1984);   //find the revenue of this year
        fprintf(outputFile,"%d",t);   //write the year in file
        fprintf(outputFile,"\t");   //write tab spaces in file
        fprintf(outputFile,"%lf",money);   //write the revenue in the file
        fprintf(outputFile, "\n");   //write new line
    }

    fclose(outputFile);    //close the file
    return 0;
}

//function to find revenue of the year t since 1984, hence t=0 is 1984,t=1 is 1985 and so on
double revenue(int t)
{
    double result;   
    result=203.265 *(pow(1.071,t));  //calculate revenue using the equation
    return result;   //return revenue
}

//function to find the year in which the revenue will reach the amount given in argument of function
int predict(double millions)
{
    int years=0;  //initial year is zero, means year is 1984
   //loop until revenue is less than what is asked
    while(revenue(years)<millions)  
    {
        years++;  //increment year
    }

    return (1984+years);   //return year in which revenue is reached the target
}

###########################################################################

OUTPUT IN FILE

so on upto the last year

############################################################################

SCREENSHOT OF CODE IN IDE


Related Solutions

The following table shows the annual returns over a six year period for the S&P 500...
The following table shows the annual returns over a six year period for the S&P 500 market index and MCH, Inc. Assume that the historical information represents a population. Use this data to calculate the correlation between both sets of security returns. Discuss your findings. Year S&P 500 MCH, Inc. 2013 0.15 0.37 2014 0.13 0.09 2015 0.14 -0.11 2016 -0.09 0.08 2017 0.12 0.11 2018 0.09 0.04 Please show me each step. Thank you
The following table shows the annual returns over a six year period for the S&P 500...
The following table shows the annual returns over a six year period for the S&P 500 market index and MCH, Inc. Assume that the historical information represents a population. Use this data to calculate the correlation between both sets of security returns. Discuss your findings. Year S&P 500 MCH, Inc. 2013 0.15 0.37 2014 0.13 0.09 2015 0.14 -0.11 2016 -0.09 0.08 2017 0.12 0.11 2018 0.09 0.04
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing...
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing on your experience from program 1, read an integer, n from keyboard (standard input). This integer represents the number of integers under consideration. After reading that initial integer in, read n integers in, and print the minimum and maximum of all the integers that are read in. Example: Input Output 7 1 5 3 6 9 22 2 Min: 1 Max: 22 C++ preferred
Hypothetical Human population matrix over a period of time of 20 year intervals. Age 0-20 20-40...
Hypothetical Human population matrix over a period of time of 20 year intervals. Age 0-20 20-40 40-60 60-80    0-20 [ .24 .98 0 0] 20-40 [ .77 0 .92 0] 40-60 [ .04 0 0 .57] 60-80 [ 0 0 0   0] Complete the calculation to determine what the population distribution will be 200 years after the initial probability distribution shown in the example as P= [1000, 1000, 1000, 1000]. The formula is P*T^10 (there are 10 sets of...
Over a 20-year period, the average sentence given to defendants convicted of aggravated assault in the...
Over a 20-year period, the average sentence given to defendants convicted of aggravated assault in the United States was 25.9 months. Assume this to be your population mean. Because you think it might be different in your home state, you conduct a little study to examine this question. You take a random sample of 175 jurisdictions in your home state and find that the mean sentence for aggravated assault is 27.3 months, with a standard deviation of 6.5. Test the...
Consider a 20-year mortgage for $282845 at an annual interest rate of 4.1%. After 6 years,...
Consider a 20-year mortgage for $282845 at an annual interest rate of 4.1%. After 6 years, the mortgage is refinanced to an annual interest rate of 2.5%. What are the monthly payments after refinancing?
In first year programming C language, using math.h, traditional stdio.h, bool.h, and mainly functions - taking approx. 85 lines of code:
In first year programming C language, using math.h, traditional stdio.h, bool.h, and mainly functions - taking approx. 85 lines of code:We often need to shuffle data in many applications. Consider a case of a game that plays cards for example or a system that does a draw for lottery. The purpose of this lab is to write functions that will help us shuffle elements of an array.Create a function that takes an array of integers and its size as parameters...
You borrow $720,000 at 3.25% per year compounded monthly and you plan to pay off this loan in equal annual payments starting one year after the loan is made over a period of fifteen (15) years.
You borrow $720,000 at 3.25% per year compounded monthly and you plan to pay off this loan in equal annual payments starting one year after the loan is made over a period of fifteen (15) years.a. What are the annual end-of-year payments? Determine the amount of interest and principal that are paid each year. What is the total interest paid for the loan?b. Restructure the loan in the previous question to make payments monthly. Determine the savings in interest overall.c....
Firm C has a tax rate = 25%; 20-year, 7% coupon, annual payment noncallable bonds selling...
Firm C has a tax rate = 25%; 20-year, 7% coupon, annual payment noncallable bonds selling for $900; 10%, $100 par value, quarterly dividend, perpetual preferred stock sells for $104; Common stock sells for $30 with D0 = $2 and g = 4%; the firm has beta = 1.2; rRF = 7%; RPM = 6%; the Bond-Yield Risk Premium = 6% and on the accounting books they have listed $2 million of bonds, $500,000 of preferred stock and $2.5 million...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT