Commit acf223478c754312d9c3c3ad715eaa6c0181cb04
1 parent
d11243fa23
Exists in
master
De-conditionals for P2-4
Showing 6 changed files with 27 additions and 3 deletions Side-by-side Diff
HW3/multiples.c
View file @
acf2234
... | ... | @@ -9,6 +9,10 @@ |
9 | 9 | scanf("%d %d %d %d %d %d", i, i+1, i+2, i+3, i+4, i+5); |
10 | 10 | for (int j = 0; j < 6; j++) { |
11 | 11 | int each = i[j]; |
12 | + d3 += (each%3 == 0); | |
13 | + d7 += (each%7 == 0); | |
14 | + d21 += (each%21 == 0); | |
15 | + /* | |
12 | 16 | if (each % 21 == 0) { |
13 | 17 | d3++; d7++; d21++; |
14 | 18 | } |
15 | 19 | |
... | ... | @@ -18,9 +22,10 @@ |
18 | 22 | else if (each % 7 == 0) { |
19 | 23 | d7++; |
20 | 24 | } |
25 | + */ | |
21 | 26 | } |
22 | 27 | /* |
23 | - d3 = 6-(i[0]%3+i[1]%3+i[2]%3+i[3]%3+i[4]%3+i[5]%3); | |
28 | + | |
24 | 29 | d7 = 6-(i[0]%7+i[1]%7+i[2]%7+i[3]%7+i[4]%7+i[5]%7); |
25 | 30 | d21 = 6-(i[0]%21+i[1]%21+i[2]%21+i[3]%21+i[4]%21+i[5]%21); |
26 | 31 | */ |
HW3/multiples.out
View file @
acf2234
HW3/rating.c
View file @
acf2234
1 | -#include <stdbool.h> | |
1 | +//#include <stdbool.h> | |
2 | 2 | #include <stdio.h> |
3 | 3 | |
4 | 4 | int main() { |
5 | 5 | char rate; |
6 | 6 | int age = 0; |
7 | - bool suit = false; | |
7 | + //bool suit = false; | |
8 | 8 | |
9 | 9 | printf("Enter the movie rating (G, P, or R): "); |
10 | 10 | scanf("%c", &rate); |
11 | 11 | printf("How old are you? "); |
12 | 12 | scanf("%d", &age); |
13 | 13 | |
14 | + printf("%s\n", (rate=='G' || (rate=='P' && age>=13) || | |
15 | + (rate=='R' && age >= 17)) ? "Suitable movie. Enjoy!" : | |
16 | + "Unsuitable movie. Enjoy the review!"); | |
17 | + | |
18 | + /* | |
14 | 19 | if (rate == 'G') { |
15 | 20 | suit = true; |
16 | 21 | } |
... | ... | @@ -28,6 +33,7 @@ |
28 | 33 | printf("Suitable movie. Enjoy!\n"); |
29 | 34 | else |
30 | 35 | printf("Unsuitable movie. Enjoy the review!\n"); |
36 | + */ | |
31 | 37 | |
32 | 38 | return 0; |
33 | 39 | } |
HW3/rating.out
View file @
acf2234
HW3/tax.c
View file @
acf2234
... | ... | @@ -19,6 +19,8 @@ |
19 | 19 | b_tax = 0.0; |
20 | 20 | printf("Salary in dollars: "); |
21 | 21 | scanf("%d", &salary); |
22 | + | |
23 | + /* | |
22 | 24 | if (salary >= 0 && salary <= TB1) { |
23 | 25 | t_tax = salary * TT1; |
24 | 26 | } |
... | ... | @@ -42,6 +44,17 @@ |
42 | 44 | else { |
43 | 45 | b_tax = BB1 * BT1 + (BB2 - BB1) * BT2 + (salary - BB2) * BT3; |
44 | 46 | } |
47 | + */ | |
48 | + | |
49 | + t_tax = (salary>TB1 && salary <= TB2)*(salary-TB1)*TT2 + (salary > | |
50 | + TB2)*(TB2-TB1)*TT2 + (salary>TB2 && | |
51 | + salary<=TB3)*(salary-TB2)*TT3 + (salary>TB3)*((TB3-TB2)*TT3 | |
52 | + + (salary-TB3)*TT4); | |
53 | + printf("Make America great again! Tax amount: $%.2lf\n",t_tax); | |
54 | + b_tax = (salary>=0 && salary<=BB1)*(salary*BT1) + | |
55 | + (salary>BB1)*(BB1*BT1) + (salary>BB1 && | |
56 | + salary<=BB2)*(salary-BB1)*BT2 + (salary>BB2)*((BB2-BB1)*(BT2) | |
57 | + + (salary-BB2)*BT3); | |
45 | 58 | printf("Jeb 2016! Tax amount: $%.2lf\n",b_tax); |
46 | 59 | |
47 | 60 | return 0; |
HW3/tax.out
View file @
acf2234