-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsalary_increase_decrease.py
More file actions
34 lines (26 loc) · 1.28 KB
/
salary_increase_decrease.py
File metadata and controls
34 lines (26 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
while True:
try:
# Prompt the user to enter the current salary
salary = float(input("Enter the current salary\n"))
# If the user has entered either zero or a negative number, prompt them to enter a valid input
if salary <= 0:
print("Invalid entry, please enter a number greater than zero.")
continue
break
except ValueError:
# If the user has entered a non-numerical input, prompt them to enter a valid input
print("Invalid entry, please enter a number greater than zero.")
# Store the salary in the original_salary variable to save it for later use during the program's execution
original_salary = salary
# Increase the salary by 10%
salary = salary + salary * 0.1
# Then, reduce the salary by 10%
salary = salary - salary * 0.1
# Calculate the salary change percentage
change_percentage = ((salary - original_salary) / original_salary) * 100
# Display the new salary
print("New salary: $" + str(round(salary, 2)) + ".")
# Display the salary change percentage, rounded to 2 decimals
print("Salary change percentage: " + str(round(change_percentage, 2)) + "%.")
# In the end, prompt the user to press Enter, in order to exit the program
input("Press Enter to exit the program")