minerva
feat: add midterm
SignedGitea couldn't verify the signature.
Showing 9 changed files with 175 additions and 12 deletions.
cis_27/assignment_4/task_1/task1deleted
+0 −0
Binary file, not shown.
cis_27/assignment_4/task_3/task3deleted
+0 −0
Binary file, not shown.
cis_27/assignment_4/task_5/task5deleted
+0 −0
Binary file, not shown.
cis_27/assignment_4/task_5/task_5.cpp
+13 −12
@@ -86,7 +86,8 @@ public:8686 }87878888 // method 6: output middle value89 void output_middle_value() {}89 void output_middle_value() { std::cout << numbers[1000 / 2] << "\n"; }909091 // method 7: output first value in the array9192 void output_first_value() {9293 std::cout << "first value in array: " << numbers[0] << "\n";@@ -165,17 +166,17 @@ int main() {165166166167 Algorithms task5;167168168 task5.output_all_values();169 task5.output_sum_all_values();170 task5.output_all_odd();171 task5.output_all_even();172 task5.linear_search(379);173 task5.output_middle_value();174 task5.output_first_value();175 task5.output_last_value();176 task5.output_highest_value_loc();177 task5.output_lowest_value_loc();178 task5.bubble_sort();169 // task5.output_all_values();170 // task5.output_sum_all_values();171 // task5.output_all_odd();172 // task5.output_all_even();173 // task5.linear_search(379);174 // task5.output_middle_value();175 // task5.output_first_value();176 // task5.output_last_value();177 // task5.output_highest_value_loc();178 // task5.output_lowest_value_loc();179 // task5.bubble_sort();179180 task5.mean_average();180181181182 return 0;
cis_27/midterm/HistoryofC++.txtadded
+4 −0
@@ -0,0 +1,4 @@1C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms.
2C++ was designed with an orientation toward system programming and embedded, resource-constrained software and large systems, with performance, efficiency, and flexibility of use as its design highlights. C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including desktop applications, video games, servers (e.g. e-commerce, web search, or SQL servers), and performance-critical applications (e.g. telephone switches or space probes).
3C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20). The C++ programming language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then amended by the C++03, C++11, C++14, and C++17 standards. The current C++20 standard supersedes these with new features and an enlarged standard library. Before the initial standardization in 1998, C++ was developed by Danish computer scientist Bjarne Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided high-level features for program organization. Since 2012, C++ is on a three-year release schedule, with C++23 the next planned standard.
4
cis_27/midterm/floatvalues.txtadded
+11 −0
@@ -0,0 +1,11 @@1150.10
2250.25
3150
4250.75
578.98
620000.65
735.99
8175.01
9129800.76
10450000.00
11-500000.50
cis_27/midterm/main.cppadded
+111 −0
@@ -0,0 +1,111 @@1// 1. read float values from floatvalues.txt into a file buffer2// 2. sum all values and output to the console3// 3. output the highest value to the console4// 4. output the lowest value to the console5// 5. append sum and mean average to the end of floatvalues.txt67#include "main.h"89#include <fstream>10#include <iomanip>11#include <iostream>1213// constructor: read float values from floatvalues.txt into the array14FloatValues::FloatValues() {15 int i = 0;16 std::ifstream file("floatvalues.txt");1718 if (file.is_open()) {19 double value;2021 while (file >> value) {22 values[i] = value;23 i++;24 }25 file.close();26 }27}2829// method 1: output all values30void FloatValues::output_all_values() {3132 for (int i = 0; i < 11; i++) {33 std::cout << values[i] << "\n";34 }35}3637// method 2: add up all values in the array38double FloatValues::get_sum() {39 double sum = 0;4041 for (int i = 0; i < 11; i++) {42 sum = sum + values[i];43 }44 return sum;45}4647// method 3: output sum of all values48void FloatValues::output_sum() { std::cout << "sum: " << get_sum() << "\n"; }4950// method 4: output highest value51void FloatValues::output_highest_value() {52 double highest_val = values[0];5354 for (int i = 0; i < 11; i++) {55 if (values[i] > highest_val) {56 highest_val = values[i];57 }58 }59 std::cout << "highest value: " << highest_val << "\n";60}6162// method 5: output lowest value63void FloatValues::output_lowest_value() {64 double lowest_val = values[0];6566 for (int i = 0; i < 11; i++) {67 if (values[i] < lowest_val) {68 lowest_val = values[i];69 }70 }71 std::cout << "lowest value: " << lowest_val << "\n";72}7374// method 6: mean average75double FloatValues::get_mean_average() { return get_sum() / 11; }7677// method 7: output mean average78void FloatValues::output_mean_average() {79 std::cout << "mean average: " << get_mean_average() << "\n";80}8182// method 8: append sum and mean average to the end of floatvalues.txt83void FloatValues::append_results() {84 std::ofstream file("floatvalues.txt", std::ios::app);8586 if (file.is_open()) {87 file << std::fixed << std::setprecision(2);88 file << "\nsum: " << get_sum() << "\n";89 file << "mean average: " << get_mean_average() << "\n";90 file.close();91 }92}9394int main() {9596 FloatValues midterm;9798 // show 2 decimal places for every number99 std::cout << std::fixed << std::setprecision(2);100101 // midterm.output_all_values();102 // midterm.output_sum();103 // midterm.output_highest_value();104 // midterm.output_lowest_value();105 midterm.output_mean_average();106 // midterm.append_results();107108 return 0;109}110111// g++ -std=c++17 -o midterm main.cpp
cis_27/midterm/main.hadded
+20 −0
@@ -0,0 +1,20 @@1class FloatValues {2public:3 double values[11];45 // constructor6 FloatValues();78 void output_all_values();910 double get_sum();11 void output_sum();1213 void output_highest_value();14 void output_lowest_value();1516 double get_mean_average();17 void output_mean_average();1819 void append_results();20};
cis_27/midterm/midterm.pyadded
+16 −0
@@ -0,0 +1,16 @@1# download historyofc++.txt2# read data into a file buffer3# count number of words present in the file (space delimeted)4# output number of words present to the console567def read_file():8 filename = "HistoryofC++.txt"910 with open(filename, "r") as file:11 buffer = file.read().split()1213 print(f"There are {len(buffer)} words in the {filename} file.")141516read_file()