diff options
| author | Fuwn <[email protected]> | 2023-05-22 15:57:00 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-05-22 15:57:00 -0700 |
| commit | 6e694de81579e5eae55a71d9f365a0cd4ae7b649 (patch) | |
| tree | b1fa5a120ba462d2395f850c50bd1ee4889f66d3 | |
| parent | chore(bin): format script (diff) | |
| download | cst120-6e694de81579e5eae55a71d9f365a0cd4ae7b649.tar.xz cst120-6e694de81579e5eae55a71d9f365a0cd4ae7b649.zip | |
| -rw-r--r-- | cst120/week_6/BUILD | 4 | ||||
| -rw-r--r-- | cst120/week_6/quiz_6.c | 41 | ||||
| -rw-r--r-- | cst120/week_6/quiz_6.h | 9 | ||||
| -rw-r--r-- | rules.bzl | 4 |
4 files changed, 56 insertions, 2 deletions
diff --git a/cst120/week_6/BUILD b/cst120/week_6/BUILD new file mode 100644 index 0000000..75d9ebd --- /dev/null +++ b/cst120/week_6/BUILD @@ -0,0 +1,4 @@ +load("//:rules.bzl", "assignment") + +assignment("quiz_6", ["quiz_6.h"]) + diff --git a/cst120/week_6/quiz_6.c b/cst120/week_6/quiz_6.c new file mode 100644 index 0000000..0cce918 --- /dev/null +++ b/cst120/week_6/quiz_6.c @@ -0,0 +1,41 @@ +/* Author: Zoltan Szabatin + * Professor: Professor Phong N. + * Project: Quiz 6 + * Course: CST 120 */ + +/* Disable security warnings when using MSVC */ +/* #ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif */ + +#include <stdio.h> /* scanf, printf */ + +#include "quiz_6.h" /* BankAccount, u_int32_t */ + +int main(void) { + struct BankAccount bank_account; + char user_go_again = 'n'; + + do { + /* Prompt for user's bank account parameters */ + printf("Enter your balance for the first month: "); + scanf("%f", &bank_account.month_one_balance); + printf("Enter monthly interest: "); + scanf("%f", &bank_account.monthly_interest); + + /* Compute monthly term */ + bank_account.monthly_term = + (u_int32_t)(bank_account.month_one_balance + + (bank_account.month_one_balance * + (bank_account.monthly_interest * 0.01f))); + + /* Output computed monthly term */ + printf("Your new balance is: %u\n", bank_account.monthly_term); + + /* Prompt user to go again */ + printf("Would you like to go again? (y/n) "); + scanf(" %c", &user_go_again); + } while (user_go_again == 'y' || user_go_again == 'Y'); + + return 0; +} diff --git a/cst120/week_6/quiz_6.h b/cst120/week_6/quiz_6.h new file mode 100644 index 0000000..c3b41e1 --- /dev/null +++ b/cst120/week_6/quiz_6.h @@ -0,0 +1,9 @@ +#include <sys/types.h> /* u_int32_t */ + +struct BankAccount { + float month_one_balance; /* in Dollars */ + float monthly_interest; /* in perecents */ + /* month_one_balance + (month_one_balance * monthly_interest) */ + u_int32_t monthly_term; +}; + @@ -1,5 +1,5 @@ -def assignment(name): +def assignment(name, extra_sources = []): native.cc_binary( name = name, - srcs = ["{}.c".format(name)], + srcs = ["{}.c".format(name)] + extra_sources, ) |