Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

I need help with this code

  Asked By: Cesar    Date: Mar 02    Category: Java    Views: 869
  

I need some help with this code which I going to
send you may be you could improve it for me if that is
possible, if thats OK for

*******************************************************


public class Teams
{

public static void main (String[] args)
{
char team1, team2, palyer; int win, loss, draw,
score1, score2, pts;

win = 3; loss = 0; draw = 1;

if(score1 > score2)

System.out.println("Enter team 1 and score" +
team1);
System.out.println("Enter team 2" + team2);
System.out.println("Enter score 1" + score1);
System.out.println("Enter score 2" + score2);

pts = win;



}
}

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Baylen Smith     Answered On: Mar 02

I think you want to read data from the console, i.g. score1 and score2 and then
compare it. Otherwise you have to assign score1 and score2 with your own values,
for example with score1 = 2 and score2 = 3.
Then you can continue with your comparison. If you want to read the data from
the console you have to do the following:

import java.io.*; //Necessary for BufferedReader

public class  Team
{
public static  void main(String[] args)
{
//After declaration of variables
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

//After declaration of the inputstream
println("Enter your score: ");
score1 = readline();
println("Enter second score: ");
score2 = readline();

//Now continue with your comparison
if(score1 > score2)
...
}
}

 
Didn't find what you were looking for? Find more on I need help with this code Or get search suggestion and latest updates.




Tagged: