Question

Assignment 5A: Moneyball. Theres a famous movie called Moneyball that was made in 2011. Its based on a true story and, if y

C++ with pseudo
0 0
Add a comment Improve this question Transcribed image text
Answer #1

step 1 : take inputs of Number of years and starting year.

step 2 :create an array a[Number of years]

step 3 : For i =0 to (Number of years-1)

                   a[i]=input the stat of year (starting year+i)

step 4 : Find the index of Max and Min of the array

step 5 : Best : starting year+Max index

            Worst: Starting year + Min index

Source code in c :

#include<stdio.h>
void main()
{
    int Numofyears; int startYear;
    printf("Enter the number of years");
    scanf("%d",&Numofyears);
    printf("Enter starting year");
    scanf("%d",&startYear);
    int a[Numofyears],i;
    for(i=0;i<Numofyears;i++)
    {
        printf("Enter stat for year %d:",(startYear+i));
        scanf("%d",&a[i]);
    }
    int max_i,min_i,max,min;
    max=-10000;

    min=10000;
    for(i=0;i<Numofyears;i++){
        if(a[i]>max)
        {
            max=a[i];
            max_i=i;
        }
    }
    for(i=0;i<Numofyears;i++){
        if(a[i]<min)
        {
            min=a[i];
            min_i=i;
        }
    }
    printf("Best stat was %d in %d",max,startYear+max_i);
    printf("Worst stat was %d in %d",min,startYear+min_i);
}

Add a comment
Know the answer?
Add Answer to:
C++ with pseudo Assignment 5A: Moneyball. There's a famous movie called Moneyball that was made in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

  • PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program tha...

    PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file  timeValidation.txt :   ...

  • The code should work exactly the same as given example. The files: ---------------------------------------------------...

    The code should work exactly the same as given example. The files: ---------------------------------------------------------------------------------------------------- -------- FILE NAME ------- album0 ---------- FILE ------- <album> 323 Licensed to Ill Beastie Boys 25.0 </album> <album> 70 Enter the Wu_Tang: 36 Cham... Wu Tang Clan 25.99 </album> turning to Alice, she went on, `What's your name, child?' and there stood the Queen in front of them, with her arms folded, <album> 115 Daydream Nation Sonic Youth 5.0 </album> <album> 414 52nd Street Billy Joel 25.75...

  • Problem 1 (Reading Statistics) Write a function called read_stats(filename) that takes a csv (comma separated values)...

    Problem 1 (Reading Statistics) Write a function called read_stats(filename) that takes a csv (comma separated values) filename as an argument and returns a 2D list containing the statistics in that file. The returned list should contain lists of stats for each crime reported and should not include the header line from the file. The file crime_in_vancouver.csv (included in the folder) has the following structure: • The first row provides headers for each column • Each subsequent row represents the stats...

  • 23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4...

    23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same...

  • This project will allow you to practice with one dimensional arrays, function and the same time...

    This project will allow you to practice with one dimensional arrays, function and the same time review the old material. You must submit it on Blackboard and also demonstrate a run to your instructor. General Description: The National Basketball Association (NBA) needs a program to calculate the wins-losses percentages of the teams. Write a complete C++ program including comments to do the following: Create the following: •a string array that holds the names of the teams •an integer array that...

  • create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines...

    create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines and using try-catch-finally blocks in your methods that read from a file and write to a file, as in the examples in the lesson notes for reading and writing text files. Input File The input file - which you need to create and prompt the user for the name of - should be called 'data.txt', and it should be created according to the instructions...

  • 23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this...

    23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same as what you had for your chapter 13 labs). The following is an example of...

  • NOTE: I ONLY NEED THE CODE FOR THIS PART: "3 - add movie and category to...

    NOTE: I ONLY NEED THE CODE FOR THIS PART: "3 - add movie and category to list for an entered year". YOU DON'T HAVE TO GIVE ME THE CODE FOR MENU OPTIONS 1, 2, pc, p, OR q BECAUSE I HAVE THAT ALREADY. ONLY 3! EDIT: THIS IS FOR PYTHON 3.8. In this assignment you are to enhance the movie list display program from Assignment 4 to help maintain a list of movies that won the Academy Award (Oscar) for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT