Commit dba78777 authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'branch4.16m' into 'master'

michael.davityan:exercise_04_16

See merge request bpcarm/trainings2017!1253
parents 8c784990 371712fc
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;
std::cout << hourlyRate * (workingHours > 40 ? 1.5 * workingHours - 20 : workingHours);
std::cout << "\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