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 } }
6 odpowiedzi
+ 7
x = 2
y = 3
total = x+y
= 2+3
total = 5
+ 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 ;)
+ 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 🤞
0
Thank you for pointing me in the right direction, but I'm still struggling to understand how to apply this to my question
0
This chapter introduces basic math operations
https://www.sololearn.com/learn/Java/2140/?ref=app
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