- 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