Commit 43103bca authored by Michael's avatar Michael

just commit

parent d39c14a5
......@@ -2,7 +2,7 @@ progname=exercise_06_33
CC=g++
CFLAGS=-Wall -Wextra -Werror -g3
all: test1 test2 test3 test4 test5 test6
all: test1 test2 test3 test4 test5 test6 test7 test8
debug/$(progname): debug/$(progname).o
$(CC) $(CFLAGS) $< -o $@
......@@ -20,11 +20,11 @@ debug:
mkdir -p debug
clean:
rm -r debug *.out
rm -r debug Tests/*.out
test%: debug/$(progname)
./debug/$(progname) < $@.in > $@.out || echo "$@ is executing..."
diff $@.out $@.expected && echo PASSED || echo FAILED
@./debug/$(progname) < Tests/$@.in > Tests/$@.out && echo "$@ is executing..."
@diff Tests/$@.out Tests/$@.expected && echo PASSED || echo FAILED
.PRECIOUS: debug/%.ii debug/%.s
.SECONDARY: debug/%.ii debug/%.s
......
#include <iostream>
#include <unistd.h>
#include <cassert>
int qualityPoints(const int averageGrade);
......@@ -6,6 +7,9 @@ int qualityPoints(const int averageGrade);
int
main()
{
if (::isatty(STDIN_FILENO)) {
std::cout << "Input student average: ";
}
int averageGrade;
std::cin >> averageGrade;
if ((averageGrade <= 0) || (averageGrade > 100)) {
......@@ -21,17 +25,14 @@ int
qualityPoints(const int averageGrade)
{
assert((averageGrade > 0) && (averageGrade <= 100));
if ((averageGrade >= 90) && (averageGrade <= 100)) {
return 4;
}
if ((averageGrade >= 80) && (averageGrade <= 89)) {
return 3;
}
if ((averageGrade >= 70) && (averageGrade <= 79)) {
return 2;
}
if ((averageGrade >= 60) && (averageGrade <= 69)) {
return 1;
int variableForAverageGrade = averageGrade / 10 % 10;
switch (variableForAverageGrade)
{
case 0 : return 4;
case 9 : return 4;
case 8 : return 3;
case 7 : return 2;
case 6 : return 1;
}
return 0;
}
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