0
Can someone help me with this exercise?
You are an administrator at a football club who must categorize already played games on the team's website. The given program takes 3 inputs: 1. match status - which checks if the match is suspended ("true") or not suspended ("false") 2. your team's score 3. opposing team's score. Complete the program so that if the match is suspended (the 1st input is "true"), it will output "Suspended". If the match is not suspended ( the1st output is false), the following statuses should be set depending on the match result: "Won", "Lost" and "Draw". Sample Input false 3 2 Sample Output Won
8 Antworten
0
Hello Elad David
Please show us your attempt so that we can help you.
0
I finaly succeeded on my own... stupid mistakes. thank you anyway 🙏
0
You are an administrator at a football club who must categorize already played games on the team's website.
The given program takes 3 inputs:
1. match status - which checks if the match is suspended ("true") or not suspended ("false")
2. your team's score
3. opposing team's score.
Complete the program so that if the match is suspended (the 1st input is "true"), it will output "Suspended".
If the match is not suspended ( the1st output is false), the following statuses should be set depending on the match result: "Won", "Lost" and "Draw".
Sample Input
false
3
2
Sample Output
Won
0
How???
0
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 == false) {if (ourScore > theirScore) {System.out.println("Won");} if (ourScore < theirScore) {System.out.println("Lost");}else{System.out.println("Draw");}} else
// your code goes here
{System.out.println("Suspended");}
}
}
Someone please help me out with this, as till case 3 it is all correct and rest 2 are locked. I am unable to rectify an error that why it isn't getting approved by SL
0
Swapnil Kamdi
Instead of the first else you need to write
if(yourScore == theirScore){ //print Draw}
0
Thanks Denise
0
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 == true)
System.out.println("suspended");
else
if (ourScore > theirScore)
System.out.println("won");
else if (ourScore == theirScore)
System.out.println("draw");
else
System.out.println("lost");
}
}
i'm not understand where i'm done mistake..! help...