0

[SOLVED] This code isnt working and I don't know why, this code is for the total salaries practice in java

public class Program { public static void main(String[] args) { Worker worker1 = new Worker(); worker1.setName("James"); worker1.setSalary(200000); Worker worker2 = new Worker(); worker2.setName("Tom"); worker2.setSalary(150000); System.out.println(CalculateTotalSalary(worker1.getSalary(),worker2.getSalary())); } //complete the function to calculate the total salary static int CalculateTotalSalary(int sal1, int sal2) { int total=sal1+sal2; return total; } } class Worker{ private String name; private int salary; public String getName() { return name; } public String setName(String newName) { this.name=newName; } public int getSalary() { return salary; } public int setSalary(int newSalary) { this.salary=newSalary; } }

15th Feb 2021, 4:53 PM
Serana Zentha
Serana Zentha - avatar
6 Answers
+ 2
I think i was clear enough ? You could have told me that i wasn't making any sense or so .
15th Feb 2021, 5:20 PM
Abhay
Abhay - avatar
0
Abhay im disliking cause I can't understand what you're saying my guy, don't take it personally. I understand now and I fixed it
15th Feb 2021, 5:02 PM
Serana Zentha
Serana Zentha - avatar
0
public class Program { public static void main(String[] args) { Worker worker1 = new Worker(); worker1.setName("James"); worker1.setSalary(200000); Worker worker2 = new Worker(); worker2.setName("Tom"); worker2.setSalary(150000); System.out.println(CalculateTotalSalary(worker1.getSalary(),worker2.getSalary())); } //complete the function to calculate the total salary static int CalculateTotalSalary(int sal1, int sal2) { int total=sal1+sal2; return total; } } class Worker{ private String name; private int salary; public String getName() { return name; } public void setName(String newName) { this.name=newName; } public int getSalary() { return salary; } public void setSalary(int newSalary) { this.salary=newSalary; } }
15th Feb 2021, 5:12 PM
Suryansh sharma
Suryansh sharma - avatar
0
Abhay its fine now i solved it, thanks for your feedback
15th Feb 2021, 5:20 PM
Serana Zentha
Serana Zentha - avatar
0
class Program { public static void main(String[] args) { //James Worker worker1 = new Worker(); worker1.name = "James"; worker1.salary = 200000; //Tom Worker worker2 = new Worker(); worker2.name = "Tom"; worker2.salary = 150000; System.out.println(CalculateTotalSalary(worker1.getSalary(),worker2.getSalary()));} //complete the function to calculate the total salary static int CalculateTotalSalary(int c,int d){int y = (c + d); return y; } class Worker{ private String name; private int salary; public String get.Name(){ return name;} public void set.Name(String newName){this.name = newName;} public int get.Salary() {return salary;} public void set.Salary(int newSalary){this.salary = newSalary;} }
16th Feb 2021, 7:49 AM
C Hri S Tatsios
C Hri S Tatsios - avatar
0
Hey there SOS what s wrong in this code why doesn't t it work???
16th Feb 2021, 7:50 AM
C Hri S Tatsios
C Hri S Tatsios - avatar