+ 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

7th Mar 2024, 10:19 PM
melvin mwango
melvin mwango - avatar
8 Antworten
+ 2
Pseudo code win = number of win tie = number of tie score = number of win + (number of tie * 0.5) print the score out
8th Mar 2024, 1:22 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 2
Hi
9th Mar 2024, 10:53 AM
Saba ali
Saba ali - avatar
+ 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.
9th Mar 2024, 12:25 PM
Rohit Krishna
Rohit Krishna - avatar
+ 1
Are you sure it is python? It looks like Java to me.
8th Mar 2024, 1:10 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 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); } }
9th Mar 2024, 12:25 PM
Rohit Krishna
Rohit Krishna - avatar
+ 1
Thnx so much
9th Mar 2024, 9:08 PM
melvin mwango
melvin mwango - avatar
0
Sorry I meant java😅
8th Mar 2024, 1:12 AM
melvin mwango
melvin mwango - avatar
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
9th Mar 2024, 3:00 AM
Elias Palavecino
Elias Palavecino - avatar