From 5bf797c3de33f678f73233314d85e3fd2258a7d2 Mon Sep 17 00:00:00 2001 From: h4sski <114345012+h4sski-programming@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:39:39 +0000 Subject: [PATCH 1/7] Add some execiutable extentions into .gitignore Based on web page: https://github.com/github/gitignore/blob/main/C%2B%2B.gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 4b64bc3c..b5e8c322 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,8 @@ node_modules .tmp npm-debug.log + +# My addition +*.exe +*.out +*.app \ No newline at end of file From 2ada0ca999d82356ec8bb68556e7ae57a9411882 Mon Sep 17 00:00:00 2001 From: h4sski <114345012+h4sski-programming@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:50:00 +0000 Subject: [PATCH 2/7] update .gitignore and done 01_02. --- .gitignore | 7 ++++--- src/Ch01/01_02b/CodeDemo.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b5e8c322..b99601da 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ node_modules npm-debug.log # My addition -*.exe -*.out -*.app \ No newline at end of file +src/Ch*.exe +src/Ch*.out +src/Ch*.app +src/Ch*. \ No newline at end of file diff --git a/src/Ch01/01_02b/CodeDemo.cpp b/src/Ch01/01_02b/CodeDemo.cpp index c4989f70..b07f36b3 100644 --- a/src/Ch01/01_02b/CodeDemo.cpp +++ b/src/Ch01/01_02b/CodeDemo.cpp @@ -1,3 +1,11 @@ // Learning C++ // Exercise 01_02 // Hello World, by Eduardo CorpeƱo + +#include + +int main(){ + std::cout << "Hi there!" << std::endl; + std::cout << std::endl << std::endl; + return (0); +} \ No newline at end of file From 7fdf85181954eeb925a7d24c48b66b1433a4a994 Mon Sep 17 00:00:00 2001 From: h4sski <114345012+h4sski-programming@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:51:19 +0000 Subject: [PATCH 3/7] update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b99601da..c2f47d55 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ npm-debug.log src/Ch*.exe src/Ch*.out src/Ch*.app -src/Ch*. \ No newline at end of file +src/Ch*.* \ No newline at end of file From 59a135bf93b26a4249641cde52bddb16bf76eb69 Mon Sep 17 00:00:00 2001 From: h4sski <114345012+h4sski-programming@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:05:44 +0000 Subject: [PATCH 4/7] Done 01_03 --- .gitignore | 8 ++++---- src/Ch01/01_03/CodeDemo.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c2f47d55..eb96b2ce 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ node_modules npm-debug.log # My addition -src/Ch*.exe -src/Ch*.out -src/Ch*.app -src/Ch*.* \ No newline at end of file +*src/Ch*.exe +*src/Ch*.out +*src/Ch*.app +*src/Ch*. \ No newline at end of file diff --git a/src/Ch01/01_03/CodeDemo.cpp b/src/Ch01/01_03/CodeDemo.cpp index 2a89889d..5c7d91df 100644 --- a/src/Ch01/01_03/CodeDemo.cpp +++ b/src/Ch01/01_03/CodeDemo.cpp @@ -7,8 +7,9 @@ int main(){ std::string str; + std::cout << "Tell me, what is your name: "; std::cin >> str; - std::cout << str; + std::cout << "Nice to meet you, " << str << "!"; std::cout << std::endl << std::endl; return (0); From 401a7773d5b571c467127ff65a1a2ac0d5184a75 Mon Sep 17 00:00:00 2001 From: h4sski <114345012+h4sski-programming@users.noreply.github.com> Date: Thu, 31 Oct 2024 21:20:00 +0000 Subject: [PATCH 5/7] Done Challange 02_13 --- src/Ch02/02_13/CodeDemo.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Ch02/02_13/CodeDemo.cpp b/src/Ch02/02_13/CodeDemo.cpp index 67b9459b..aa7f728d 100644 --- a/src/Ch02/02_13/CodeDemo.cpp +++ b/src/Ch02/02_13/CodeDemo.cpp @@ -7,8 +7,11 @@ int main(){ int nums[5] = {1,23,32,24,337}; float result; + int sum; // Write your code here + sum = nums[0] + nums[1] + nums[2] + nums[3] + nums[4]; + result = sum / 5.0f; std::cout << "The average is " << result << std::endl; From 8b306e4aeb67dc43aee901604b3d8f58836cf07f Mon Sep 17 00:00:00 2001 From: h4sski <114345012+h4sski-programming@users.noreply.github.com> Date: Sat, 2 Nov 2024 20:16:54 +0000 Subject: [PATCH 6/7] done chellange 03_11 --- src/Ch03/03_11/records.cpp | 44 +++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Ch03/03_11/records.cpp b/src/Ch03/03_11/records.cpp index b55b5298..3fae3d1a 100644 --- a/src/Ch03/03_11/records.cpp +++ b/src/Ch03/03_11/records.cpp @@ -1 +1,43 @@ -// Write your implementation code here \ No newline at end of file +// Write your implementation code here +#include "records.h" + +Student::Student(int the_id, std::string the_name){ + id = the_id; + name = the_name; +}; +int Student::get_id() const{ + return id; +}; +std::string Student::get_name() const{ + return name; +}; + +Course::Course(int the_id, std::string the_name, unsigned char the_credits){ + id = the_id; + name = the_name; + credits = the_credits; +}; +int Course::get_id() const{ + return id; +}; +std::string Course::get_name() const{ + return name; +}; +int Course::get_credits() const{ + return credits; +}; + +Grade::Grade(int the_sid, int the_cid, char the_grd) { + student_id = the_sid; + course_id = the_cid; + grade = the_grd; +}; +int Grade::get_student_id() const{ + return student_id; +}; +int Grade::get_course_id() const{ + return course_id; +}; +char Grade::get_grade() const{ + return grade; +}; \ No newline at end of file From fe357532a5af551991d04e47403862891ea479ac Mon Sep 17 00:00:00 2001 From: h4sski <114345012+h4sski-programming@users.noreply.github.com> Date: Sat, 2 Nov 2024 21:33:08 +0000 Subject: [PATCH 7/7] Done challange 04_05 --- src/Ch04/04_05/CodeDemo.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Ch04/04_05/CodeDemo.cpp b/src/Ch04/04_05/CodeDemo.cpp index 58e1c596..b474bf0e 100644 --- a/src/Ch04/04_05/CodeDemo.cpp +++ b/src/Ch04/04_05/CodeDemo.cpp @@ -9,6 +9,7 @@ int main(){ float GPA = 0.0f; int id; + int total_credits = 0; std::vector students = {Student(1, "George P. Burdell"), Student(2, "Nancy Rhodes")}; @@ -26,9 +27,38 @@ int main(){ // Calculate the GPA for the selected student. // Write your code here + for (Grade& grade : grades){ + if (grade.get_student_id() == id){ + int credit = 0; + for (auto course : courses){ + if (grade.get_course_id() == course.get_id()) + credit = course.get_credits(); + }; + total_credits += credit; + switch (grade.get_grade()){ + case 'A': + GPA += 4*credit; + break; + case 'B': + GPA += 3*credit; + break; + case 'C': + GPA += 2*credit; + break; + case 'D': + GPA += 1*credit; + break; + default: + GPA += 0*credit; + break; + }; + }; + }; + + GPA /= total_credits; std::string student_str; - student_str = students[0].get_name(); // Change this to the selected student's name + student_str = students[id-1].get_name(); // Change this to the selected student's name std::cout << "The GPA for " << student_str << " is " << GPA << std::endl;