diff --git a/c_modern_approach/Fundamentials/README.md b/c_modern_approach/Fundamentials/README.md index 9bde271..ee24be2 100644 --- a/c_modern_approach/Fundamentials/README.md +++ b/c_modern_approach/Fundamentials/README.md @@ -11,3 +11,4 @@ After Preprocessing app goes to compiler where app is being translated into mach Linker combines object code from step 2 with additional code needed for final executable. This code includes library functions P.S.: *Сори за микс языков, лень было переключаться в процессе* +sdfaksdhfk diff --git a/c_modern_approach/Fundamentials/exercises/s_2_1.c b/c_modern_approach/Fundamentials/exercises/2/s_2_1.c similarity index 100% rename from c_modern_approach/Fundamentials/exercises/s_2_1.c rename to c_modern_approach/Fundamentials/exercises/2/s_2_1.c diff --git a/c_modern_approach/Fundamentials/exercises/s_2_2.c b/c_modern_approach/Fundamentials/exercises/2/s_2_2.c similarity index 100% rename from c_modern_approach/Fundamentials/exercises/s_2_2.c rename to c_modern_approach/Fundamentials/exercises/2/s_2_2.c diff --git a/c_modern_approach/Fundamentials/exercises/s_2_4.c b/c_modern_approach/Fundamentials/exercises/2/s_2_4.c similarity index 100% rename from c_modern_approach/Fundamentials/exercises/s_2_4.c rename to c_modern_approach/Fundamentials/exercises/2/s_2_4.c diff --git a/c_modern_approach/Fundamentials/exercises/s_2_7.c b/c_modern_approach/Fundamentials/exercises/2/s_2_7.c similarity index 100% rename from c_modern_approach/Fundamentials/exercises/s_2_7.c rename to c_modern_approach/Fundamentials/exercises/2/s_2_7.c diff --git a/c_modern_approach/Fundamentials/exercises/2_1 b/c_modern_approach/Fundamentials/exercises/2_1 deleted file mode 100755 index 6d97fba..0000000 Binary files a/c_modern_approach/Fundamentials/exercises/2_1 and /dev/null differ diff --git a/c_modern_approach/Fundamentials/exercises/2_4 b/c_modern_approach/Fundamentials/exercises/2_4 deleted file mode 100755 index 378db81..0000000 Binary files a/c_modern_approach/Fundamentials/exercises/2_4 and /dev/null differ diff --git a/c_modern_approach/Fundamentials/projects/2/main.c b/c_modern_approach/Fundamentials/projects/2/main.c new file mode 100644 index 0000000..3f5f262 --- /dev/null +++ b/c_modern_approach/Fundamentials/projects/2/main.c @@ -0,0 +1,108 @@ +#include +#include + +float calculate_volume(void) { + float radius; + printf("Hello from calculator\n"); + printf("Please, enter the radius of circle in meters: "); + scanf("%f", &radius); + float division = 4.0 / 3.0; + float volume = division * M_PI * radius * radius * radius; + return volume; +} + +float tax_calculator(void) { + float rubles, cents; + printf("Please, enter the rubles amount: "); + scanf("%f", &rubles); + printf("Please, enter the cents amount: "); + scanf("%f", ¢s); + float result = (rubles + (cents / 100)) * 1.05; + return result; +} + +void change_calculator(void) { + int rubles; + printf("Please, enter the rubles amount: "); + scanf("%d", &rubles); + /* In Russia, we have following bills: + * 5000 rubles + * 2000 rubles + * 1000 rubles + * 500 rubles + * 200 rubles + * 100 rubles + * 50 rubles + * 10 rubles + * 1 ruble - we actually does not have 1 ruble bill, but for the sake of + * project we have + */ + // Calculate for 5000 + int _5k_bills = rubles / 5000; + // Remove this amount from total + rubles = rubles - _5k_bills * 5000; + // Calculate for 2000 for remeaning + int _2k_bills = rubles / 2000; + // Remove this amount from total + rubles = rubles - _2k_bills * 2000; + // Calculate for 1000 for remeaning + int _1k_bills = rubles / 1000; + // Remove this amount from total + rubles = rubles - _1k_bills * 1000; + // Calculate for 500 for remeaning + int _500_bills = rubles / 500; + // Remove this amount from total + rubles = rubles - _500_bills * 500; + // Calculate for 200 for remeaning + int _200_bills = rubles / 200; + // Remove this amount from total + rubles = rubles - _200_bills * 200; + // Calculate for 100 for remeaning + int _100_bills = rubles / 100; + // Remove this amount from total + rubles = rubles - _100_bills * 100; + // Calculate for 50 for remeaning + int _50_bills = rubles / 50; + // Remove this amount from total + rubles = rubles - _50_bills * 50; + // Calculate for 10 for remeaning + int _10_bills = rubles / 10; + // Remove this amount from total + rubles = rubles - _10_bills * 10; + // Print result + printf("5000 bills\t%d\n", _5k_bills); + printf("2000 bills\t%d\n", _2k_bills); + printf("1000 bills\t%d\n", _1k_bills); + printf("500 bills\t%d\n", _500_bills); + printf("200 bills\t%d\n", _200_bills); + printf("100 bills\t%d\n", _100_bills); + printf("50 bills\t%d\n", _50_bills); + printf("10 bills\t%d\n", _10_bills); + printf("1 bills\t\t%d\n", rubles); +} + +void load_calculator(void) { + float loan, interest_rate, monthly_payment; + loan = 20000.00; + interest_rate = 6.0; + monthly_payment = 386.66; + float monthly_interest_rate = (interest_rate / 100) / 12; + loan = loan + (loan * monthly_interest_rate) - monthly_payment; + printf("LN\t%.2f\n", loan); + loan = loan + (loan * monthly_interest_rate) - monthly_payment; + printf("LN\t%.2f\n", loan); + loan = loan + (loan * monthly_interest_rate) - monthly_payment; + printf("LN\t%.2f\n", loan); +} + +int main() { + /* float volume = calculate_volume(); */ + /* printf("%f", volume); */ + + /* float tax = tax_calculator(); */ + /* printf("%.2f", tax); */ + + /* change_calculator(); */ + + load_calculator(); +} diff --git a/c_modern_approach/Fundamentials/projects/2/res b/c_modern_approach/Fundamentials/projects/2/res new file mode 100755 index 0000000..405fece Binary files /dev/null and b/c_modern_approach/Fundamentials/projects/2/res differ