Primitive Operators HR Budget Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Primitive Operators HR Budget Question

I'm pretty lost on how to approach this. I'm given a sample input of 1500 and 3200 and a sample output of 4700. There are two employees and I have to write a program to take their salaries 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 } }

9th Jun 2021, 5:58 AM
Pablo Sandoval
Pablo Sandoval - avatar
6 Answers
+ 7
x = 2 y = 3 total = x+y = 2+3 total = 5
9th Jun 2021, 6:06 AM
Simba
Simba - avatar
+ 1
If the task request you to output the sum of both salary, you must compute it as showed by Simba and print the result either directly or by printing the variable wich store the result... if you do not have idea of how to print something, you should go back to the lesson and read/learn it more closely ;)
9th Jun 2021, 9:00 AM
visph
visph - avatar
+ 1
It was simpler than I thought 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 sum = salary1+salary2; System.out.println(sum); } } The thing is that you don't have to input any numbers, just make a formula just by adding this int sum = salary1+salary2; System.out.println(sum); Hope this helps you, and good luck 🤞
14th Jun 2021, 11:14 PM
Мирбек Исмаилов
Мирбек Исмаилов - avatar
0
Thank you for pointing me in the right direction, but I'm still struggling to understand how to apply this to my question
9th Jun 2021, 6:17 AM
Pablo Sandoval
Pablo Sandoval - avatar
0
This chapter introduces basic math operations https://www.sololearn.com/learn/Java/2140/?ref=app
9th Jun 2021, 6:44 AM
Ipang
0
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 sum = salary1 + salary2; System.out.println(sum); } } Good Luck
26th Jan 2022, 6:16 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar