ISourceCode

Make the frequent cases fast and the rare case correct

Algorithm to find total number of matches drawn at the end of EPL

Given the total number of matches played in English Premier League. It is required to find the total number of matches that were drawn.The total points each team scored must be an input to the algorithm

import java.util.*;
import java.io.*;

public class league
{
	public static void main(String[] args){
	Scanner input=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
	int num,points;
	System.out.println("Enter the number of teams");
		
	num=input.nextInt();
		
	if (num==0)
	{
		System.out.println("No teams entered");
	}
	System.out.println("Enter the total number of matches played in the league");
	points=3*input.nextInt();
	System.out.println("Enter the team and the points scored");
	for (int i=0;i< num ;i++ )
	{
		input.next();
		points=points-input.nextInt();
	}
	
	System.out.println("The Total number of matched that were drawn are: "+points);
	
 	}
}

2009-2010 EPL season standings

labuser@ubuntu:~$ java league
Enter the number of teams
20
Enter the total number of matches played in the league
380
Enter the team and the points scored
Chelsea 86
ManUtd 85
Arsenal 75
Tottenham 70
ManchesterCity 67
AstonVilla 64
Liverpool 63
Everton 61
Birmingham 50
Blackburn 50
StokeCity 47
Fulham 46
Sunderland 44
Bolton 39
Wolves 38
WiganAthletic 36
WestHamUtd 35
Burnley 30
HullCity 30
Portsmouth 19
The Total number of matched that were drawn are: 105

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: