+ 2
I need help
Am trying to solve this code in python but it keeps giving me errors. The question is about two variables, which are wins and ties, am supposed to calculate and provide output of the code, please note that am supposed to multiply the value of the ties by 0.5 to get the answer. Please help.the question: public class Program { public static void main(String[] args) { int wins = 54; int ties = 31; Thanks
8 Respostas
+ 2
Pseudo code
win = number of win
tie = number of tie
score = number of win + (number of tie * 0.5)
print the score out
+ 2
Hi
+ 2
To solve this problem in Java, you need to declare the variables wins and ties, then calculate the total score by adding wins to half of ties. Here's how you can do it:public class Program {
public static void main(String[] args) {
int wins = 54;
int ties = 31;
double totalScore = wins + (ties * 0.5);
System.out.println("Total score: " + totalScore);
}
}This will give you the total score by adding the wins to half of the ties. Note that we're using a double type for totalScore to accommodate the fractional result from multiplying ties by 0.5.
+ 1
Are you sure it is python?
It looks like Java to me.
+ 1
public class Program {
public static void main(String[] args) {
int wins = 54;
int ties = 31;
double totalScore = wins + (ties * 0.5);
System.out.println("Total score: " + totalScore);
}
}
+ 1
Thnx so much
0
Sorry I meant java😅
0
you need to use float in ties not int since you are multiplying by 0.5 wich is a float (im asuming you decleared 0.5 as a float as it should be), anyway you can also use int but divide by 2 instead of multying by 0.5