0% found this document useful (0 votes)
42 views

Teams

kml,l
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Teams

kml,l
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Class File:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package javaapplication1;

import java.util.Scanner;

/**

* @author Mohammad Noor

*/

public class Teams {

public String teamname;

public String captain;

public int gamesplayed;

public int gameswon;

public int yearjoined;

public int ranking;

public void writeInput()

Scanner r = new Scanner(System.in);

System.out.println("Enter Team Name");

teamname=r.next();

System.out.println("Enter Captain Name");

captain=r.next();

System.out.println("Enter Games Played");

gamesplayed=r.nextInt();

System.out.println("Enter Games Won");


gameswon=r.nextInt();

System.out.println("Enter Year Joined");

yearjoined=r.nextInt();

System.out.println("Enter Year Ranking");

ranking=r.nextInt();

public void getoutput()

System.out.println("Team Name: "+teamname+" " +"Captain Name:"+captain+"


"+"GamesPlayed:"+gamesplayed+" "+"GamesWon"+gameswon+" "+"Year Joined"+yearjoined+"
"+"Ranking:"+ranking );

/** Creates a new instance of Teams */

public String getTeamname()

return teamname;

public void SetCaptainname(String a)

captain=a;

public int noofgames()

Scanner v = new Scanner(System.in);

System.out.println("Enter Games Played");

gamesplayed=v.nextInt();
int t;

t=50;

t=t-gamesplayed;

System.out.println("No of games Played out of 50="+t);

return t;

public float percentage()

Scanner v = new Scanner(System.in);

System.out.println("Enter Games Won");

gameswon=v.nextInt();

float win;

win=(float)((gameswon*100)/gamesplayed);

System.out.println("No of games Won out of 50="+win);

return win;

Main File:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package javaapplication1;

import java.util.Scanner;

/**

* @author Mohammad Noor

*/
public class JavaApplication1 {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Teams T1,T2;

T1=new Teams();

T2=new Teams();

T1.writeInput();

T1.getoutput();

T1.getTeamname();

Scanner y = new Scanner(System.in);

String a;

System.out.println("Set Captain Name for Team 1");

a=y.next();

T1.SetCaptainname(a);

T1.noofgames();

T1.percentage();

You might also like