You have two employees in your organization. Write a program to take their salaries as input and print them both out. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
- 5

You have two employees in your organization. Write a program to take their salaries as input and print them both out.

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //get salaries int salary1 = scanner.nextInt(); int salary2 = scanner.nextInt(); //your code goes here int salarytotal = scanner.nextInt(salary1 + salary2); } } I am new to this programming World. Could anyone please help me out with this ?

2nd Jul 2021, 9:41 PM
Sanchit Bahl
Sanchit Bahl - avatar
2 Respostas
+ 1
You took salaries in ā€œget salariesā€ part, all you need is just print them You can print text and variables with System.out.println() For print them separately: System.out.println(ā€œsalary1 is : ā€œ + salary1); System.out.println(salary2 is : ā€œ + salary2); For print just sum of them: int sum = salary1 + salary2; System.out.println(ā€œsum of salaries :ā€ + sum);
2nd Jul 2021, 11:01 PM
MohammaD ReZa
MohammaD ReZa - avatar
- 3
In this task, you need to withdraw the amount of salaries. Given the mistake you made, you need to reread the lessons on data input and output.
2nd Jul 2021, 10:17 PM
Solo
Solo - avatar