Challenge: Find the Person with the Highest Salary
Test your understanding of the concepts we have covered so far by solving a simple challenge in this lesson.
We'll cover the following
Problem statement
In this challenge, you are provided with the salaries of two people. Your task is to find the person with the highest salary.
Input
We have already initialized the variables salary1
and salary2
at the backend.
salary1
belongs to person1.salary2
belongs to person2.
Output
-
If person1 has the highest salary, your program should print
person1
to the console. -
If person2 has the highest salary, your program should print
person2
to the console.
Sample input
int salary1 = 56000;
int salary2 = 89000;
Sample output
person2
Coding exercise
Before diving directly into the solution, try to solve it yourself. Then, check if your code passes all the test cases.
📝 Please use the variables
salary1
andsalary2
for the input and print your output to the console, or your code will not execute.
📝
salary1
andsalary2
cannot have equal values.
Good luck! 👍
Get hands-on with 1400+ tech skills courses.