- 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 ?
2 RĂ©ponses
+ 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);
- 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.