Commit 4abdb201 authored by Michael's avatar Michael

michael.davityan:exercise_04_16

parent 8072b1eb
Pipeline #23046457 passed with stage
in 3 minutes 5 seconds
dbg: debug/exercise_04_16
debug/exercise_04_16: debug/exercise_04_16.o
g++ -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_16.o: debug/exercise_04_16.s
g++ -c -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_16.s: debug/exercise_04_16.ii
g++ -S -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_16.ii: exercise_04_16.cpp
g++ -E -Wall -Wextra -Werror -g3 $< -o $@
debug/exercise_04_16.ii: | debug
debug:
mkdir -p debug
clean:
rm -rf debug *.ii *.s *.o *.out .gitignore
test: debug/exercise_04_16
./debug/exercise_04_16 < test1.in > test1.out || echo "Test 1 is executing..."
diff test1.out test1.expected && echo PASSED || echo FAILED
.PRECIOUS: exercise_04_16.ii exercise_04_16.s
.SECONDARY: exercise_04_16.ii exercise_04_16.s
#include <iostream>
#include <iomanip>
#include <unistd.h>
int
main()
{
while (true) {
if (::isatty(STDIN_FILENO)) {
std::cout << "Enter hours worked (-1 to end): ";
}
int workingHours;
std::cin >> workingHours;
if (-1 == workingHours) {
return 0;
}
if (::isatty(STDIN_FILENO)) {
std::cout << "Enter hourly rate of the worker ($00.00): ";
}
double hourlyRate;
std::cin >> hourlyRate;
std::cout << "Salary is $" << std::setprecision(2) << std::fixed << (workingHours > 40 ?
40 * hourlyRate + (workingHours - 40) * 1.5 * hourlyRate : workingHours * hourlyRate)
<< "\n"<< std::endl;
}
return 0;
}
Salary is $390.00
Salary is $400.00
Salary is $415.00
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment