Ask C/C++ Expert


Home >> C/C++

 

How do you get this program to get both player input and then display results(As described on bottom)

#include

const int NUM_YEARS=15;//The number of years

const int NAME_SIZE=32;//The max size of the player name string

const int POINTS_GAME=16;

const int MIN_YEAR=2001;//The lowest year is 1999

const int MAX_YEAR=2014;//The highest year is 2014

int getYear(int count);

int binarySearch(int [],int,int);

void displayProd(char[][NAME_SIZE]);/////INCOMPLETE

int main()

{;

int yr[NUM_YEARS]={2001,2002,2003,2004,2005,2006,2007,2008,

2009,2010,2011,2012,2013,2014};

?

//MVP Names from 1999-2014

char names[NUM_YEARS][NAME_SIZE]=

{

"Allen Iverson",

"Tim Duncan",

"Tim Duncan",

"Kevin Garnett",

"Steve Nash",

"Steve Nash",

"Dirk Nowitzki",

"Kobe Bryant",

"LeBron James",

"LeBron James",

"Derrick Rose",

"LeBron James",

"LeBron James",

"Kevin Durant"

};

char description[NUM_YEARS][POINTS_GAME]=

{

"31.1",

"25.5",

"23.3",

"24.2",

"15.5",

"18.8",

"24.6",

"28.3",

"28.4",

"29.7",

"25.0",

"27.1",

"26.8",

"32.0"

};

int yrNum;

int index;

int index_2;

int c=0;

do

{

yrNum=getYear(c);

index=binarySearch(yr,NUM_YEARS,yrNum);

if(index==-1)

cout<<"That product number was not found.\n";

else

cout<<"Player: "<< names[index]<

cout<<"PPG: "<

c++;

}while(true);

system("pause");

system("cls");

return 0;

}

int getYear(int count)

{

int yearNum;

cout<<"Displays MVPs from 2000-2001 season to 2013-2014"<

cout<<"Example 2004-2005 season you would enter 2005."<

cout<<"Enter the year from the 2000-2001 season to 2013-2014: \n";

cout<<"Enter player "<<((count%2)+1)<

cin>>yearNum;

while(yearNumMAX_YEAR)

{

cout<<"Please enter between 2001 and 2014\n";

cin>>yearNum;

}

int t=0;

count=yearNum;

t=count;

return t;

?

}

int binarySearch(int array[], int numElems, int value)

{

int first = 0, // First array element

last = numElems-1, // Last array element

middle, // Mid point of search

position = -1; // Position of search value

bool found = false; // Flag

while (!found && first <= last)

{

middle = (first + last) / 2; // Calculate mid point

if (array[middle] == value) // If value is found at mid

{

found = true;

position = middle;

}

else if (array[middle] > value) // If value is in lower half

last = middle - 1;

else

first = middle + 1; // If value is in upper half

}

return position;

}

Displays MVPs from 2000-2001 season to 2013-2014
Example 2004-2005 season you would enter 2005.
Enter the year from the 2000-2001 season to 2013-2014:
Enter player 1
2001
Player: Allen Iverson
PPG: 31.1
Displays MVPs from 2000-2001 season to 2013-2014
Example 2004-2005 season you would enter 2005.
Enter the year from the 2000-2001 season to 2013-2014:
Enter player 2
2005
Player: Steve Nash
PPG: 15.5
Displays MVPs from 2000-2001 season to 2013-2014
Example 2004-2005 season you would enter 2005.
Enter the year from the 2000-2001 season to 2013-2014:
Enter player 1

HOW DO YOU GET IT LIKE THIS

Displays MVPs from 2000-2001 season to 2013-2014
Example 2004-2005 season you would enter 2005.
Enter the year from the 2000-2001 season to 2013-2014:

Displays MVPs from 2000-2001 season to 2013-2014

Enter the year from the 2000-2001 season to 2013-2014:
Enter player 1: 2001

Enter player 2: 2005

2001
Player: Allen Iverson PPG:

31.1

2005
Player: Steve Nash
PPG: 15.5

 

 

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9451563

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As