0
Java 12.2
Ребят кто решил задачу? Покажите решение. show the solution to the problem
14 odpowiedzi
+ 5
Igaman Igaman
Yes show the attempts of the problem.
Да покажите попытки проблемы.
+ 3
Igaman Igaman
The correct solution is
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
boolean isSuspended = read.nextBoolean();
int ourScore = read.nextInt();
int theirScore = read.nextInt();
if (isSuspended) {
System.out.println("Suspended");
} else {
if(ourScore < theirScore) {
System.out.println("Lost");
} else if(ourScore > theirScore) {
System.out.println("Won");
} else { //no need to check equality
System.out.println("Draw");
}
}
+ 2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
boolean isSuspended = read.nextBoolean();
int ourScore = read.nextInt();
int theirScore = read.nextInt();
int x,y;
if (false) {
if(z < y) {
System.out.println("Lost");
} else if(x > y) {
System.out.println("Win");
} else if(x == y) {
System.out.println("Draw");
} else {
System.out.println("Suspended");
}
}
}
}
+ 2
Igaman Igaman
Why there is Hard Code condition if(false) if you have an input isSuspended?
Почему существует условие Hard Code if (false), если у вас есть вход isSuspended?
+ 2
Igaman Igaman
And why there are x and y when ourScore and theirScore are given?
И почему есть x и y, когда даны ourScore и theirScore?
+ 2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
boolean isSuspended = read.nextBoolean();
int ourScore = read.nextInt();
How get suspended if true?
int theirScore = read.nextInt();
if(ourScore < theirScore) {
System.out.println("Lost");
} else if(ourScore > theirScore) {
System.out.println("Win");
} else if(ourScore == theirScore) {
System.out.println("Draw");
}
}
}
+ 2
Igaman Igaman
Because there is Won not Win so just change Win to Won
+ 1
I'm confused, can you explain?
+ 1
You are the administrator of the football club and must categorize the games that have already been played on the team's website.
The program takes 3 inputs:
1. match status - which determines whether the match was postponed ("true") or not ("false")
2. your team points
3. points of the opposing team.
Modify the program so that if the match is postponed (the first input value is "true"), it displays "Suspended".
If the match has not been postponed (the first entered value is false), then, depending on the result of the match, one of the following statuses must be set: "Won", "Lost" and "Draw".
Sample input
false
3
2
+ 1
I have incorrectly translated ourscore and theirscore :(
+ 1
now I'll try to solve
+ 1
How get “suspended” if true?
0
Wow))) thats easy, but closed test 5 is wrong
0
Its working!!!!! Thank you!)