Java 12.2 | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Java 12.2

–†–Ķ–Ī—Ź—ā –ļ—ā–ĺ —Ä–Ķ—ą–ł–Ľ –∑–į–ī–į—á—É? –ü–ĺ–ļ–į–∂–ł—ā–Ķ —Ä–Ķ—ą–Ķ–Ĺ–ł–Ķ. show the solution to the problem

18th Apr 2021, 6:22 AM
Igaman Igaman
Igaman Igaman - avatar
14 Respuestas
+ 5
Igaman Igaman Yes show the attempts of the problem. –Ē–į –Ņ–ĺ–ļ–į–∂–ł—ā–Ķ –Ņ–ĺ–Ņ—č—ā–ļ–ł –Ņ—Ä–ĺ–Ī–Ľ–Ķ–ľ—č.
18th Apr 2021, 6:36 AM
AÕĘJ
AÕĘJ - avatar
+ 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"); } }
18th Apr 2021, 8:45 AM
AÕĘJ
AÕĘJ - avatar
+ 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"); } } } }
18th Apr 2021, 6:38 AM
Igaman Igaman
Igaman Igaman - avatar
+ 2
Igaman Igaman Why there is Hard Code condition if(false) if you have an input isSuspended? –ü–ĺ—á–Ķ–ľ—É —Ā—É—Č–Ķ—Ā—ā–≤—É–Ķ—ā —É—Ā–Ľ–ĺ–≤–ł–Ķ Hard Code if (false), –Ķ—Ā–Ľ–ł —É –≤–į—Ā –Ķ—Ā—ā—Ć –≤—Ö–ĺ–ī isSuspended?
18th Apr 2021, 6:54 AM
AÕĘJ
AÕĘJ - avatar
+ 2
Igaman Igaman And why there are x and y when ourScore and theirScore are given? –ė –Ņ–ĺ—á–Ķ–ľ—É –Ķ—Ā—ā—Ć x –ł y, –ļ–ĺ–≥–ī–į –ī–į–Ĺ—č ourScore –ł theirScore?
18th Apr 2021, 6:58 AM
AÕĘJ
AÕĘJ - avatar
+ 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"); } } }
18th Apr 2021, 7:43 AM
Igaman Igaman
Igaman Igaman - avatar
+ 2
Igaman Igaman Because there is Won not Win so just change Win to Won
18th Apr 2021, 8:53 AM
AÕĘJ
AÕĘJ - avatar
+ 1
I'm confused, can you explain?
18th Apr 2021, 6:56 AM
Igaman Igaman
Igaman Igaman - avatar
+ 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
18th Apr 2021, 6:57 AM
Igaman Igaman
Igaman Igaman - avatar
+ 1
I have incorrectly translated ourscore and theirscore :(
18th Apr 2021, 7:00 AM
Igaman Igaman
Igaman Igaman - avatar
+ 1
now I'll try to solve
18th Apr 2021, 7:01 AM
Igaman Igaman
Igaman Igaman - avatar
+ 1
How get ‚Äúsuspended‚ÄĚ if true?
18th Apr 2021, 7:44 AM
Igaman Igaman
Igaman Igaman - avatar
0
Wow))) thats easy, but closed test 5 is wrong
18th Apr 2021, 8:51 AM
Igaman Igaman
Igaman Igaman - avatar
0
Its working!!!!! Thank you!)
18th Apr 2021, 9:11 AM
Igaman Igaman
Igaman Igaman - avatar