Skip to content

Maarufvazifdar_117509717_Week4 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 28 additions & 0 deletions Week_3/AcceleratedC++_3-5/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.2.1)
project (scratch)

# Add project cmake modules to path.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)

# We probably don't want this to run on every build.
option(COVERAGE "Generate Coverage Data" OFF)

if (COVERAGE)
include(CodeCoverage)
set(LCOV_REMOVE_EXTRA "'vendor/*'")
setup_target_for_coverage(code_coverage test/cpp-test coverage)
set(COVERAGE_SRCS app/main.cpp include/lib.hpp)

SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_EXE_LINKER_FLAGS "-fprofile-arcs -ftest-coverage")
else()
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -g")
endif()

include(CMakeToolsHelpers OPTIONAL)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 14)

add_subdirectory(app)
add_subdirectory(test)
Binary file added Week_3/AcceleratedC++_3-5/UML_diagram.pdf
Binary file not shown.
61 changes: 61 additions & 0 deletions Week_3/AcceleratedC++_3-5/app/AcceleratedC++_3-5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @file AcceleratedC++_3-5.cpp
* @brief Week3 Assignment Problem.
*
* @copyright
*
* @author Maaruf Vazifdar
*
* @date 09-17-2021
*/
#include<iostream>
#include<vector>
#include<string>

/** @brief Function to input student name, their marks in a subject
* and assign grade accordingly.
* @param none
* @return void
*/
void StudentInfo() {
std::vector<std::string> StudentName;
std::vector<char> StudentGrade;
int StudentMarks;
std::string SName;
char Ans;
do {
std::cout << "Enter student name: " << std::endl;
std::cin >> SName;
StudentName.push_back(SName);
std::cout << "Enter student marks: " << std::endl;
std::cin >> StudentMarks;
switch (StudentMarks) {
case 91 ... 100:
StudentGrade.push_back('A');
break;
case 81 ... 90:
StudentGrade.push_back('B');
break;
case 51 ... 80:
StudentGrade.push_back('C');
break;
case 0 ... 50:
StudentGrade.push_back('F');
break;
default:
break;
}
std::cout << "Do you want to enter more student info? (y or n): "
<< std::endl;
std::cin >> Ans;
} while (Ans == 'y');

for (unsigned int i = 0; i < (StudentName.size()); i++) {
std::cout << "\n" << StudentName[i] << " : " << StudentGrade[i];
}
}

int main() {
StudentInfo();
return 0;
}
7 changes: 7 additions & 0 deletions Week_3/AcceleratedC++_3-5/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_executable(shell-app main.cpp)
add_executable(AcceleratedC++_3-5 AcceleratedC++_3-5.cpp)


include_directories(
${CMAKE_SOURCE_DIR}/include
)
File renamed without changes.
File renamed without changes.
94 changes: 94 additions & 0 deletions Week_3/AcceleratedC++_3-5/include/SoftwareEngineering_3_10.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @file SoftwareEngineering_3_10.h
* @brief A header file for Week3 Assignment Problem.
*
* @copyright
*
* @author Maaruf Vazifdar
*
* @date 09-17-2021
*/

#ifndef SOFTWAREENGINEERING_3_10_H
#define SOFTWAREENGINEERING_3_10_H
#include <iostream>

/** @brief A class for course grading for students. It has members to update
* the student grade and compute grade point average of the class.
*/
class RoboticsClass {
private:
int Student[5] = { 1, 2, 3, 4, 5 };
char StudentGrade[5] = { 'A', 'B', 'C', 'D', 'E' };
int StudentNo;
float ClassGradePointAvg;
char Ans, NewGrade;
float GradeSum = 0;

public:
/** @brief Member function that takes student id, displays student's
* grade and provides option to update the grade.
* @param none
* @return void
*/
void UpdateStudentGrade() {
std::cout << "Enter Student No.: ";
std::cin >> StudentNo;
std::cout << "Student " << StudentNo << "'s current grade is: "
<< StudentGrade[StudentNo - 1] << "." << std::endl;
std::cout << "Do you want to update Grade? (y or n).";
std::cin >> Ans;
if (Ans == 'y' || Ans == 'Y') {
std::cout << "Enter new Grade: ";
std::cin >> NewGrade;
StudentGrade[StudentNo - 1] = NewGrade;
std::cout << "Student " << StudentNo << "'s Grade updated to: "
<< StudentGrade[StudentNo - 1] << std::endl;
}
}

/** @brief Member function that computes the grade point average of the class.
* Grade Scale: A - 5
* B - 4
* C - 3
* D - 2
* E - 1
* F - 0
* @param none
* @return void
*/
void CalcGradePointAvg() {
std::cout << "Grade Scale:" << std::endl;
std::cout << "A = 5 \nB = 4 \nC = 3 \nD = 2 \nE = 1 \nF = 0" << std::endl;
for (int i = 0; i <= (sizeof(StudentGrade) - sizeof(StudentGrade[0]));
i++) {
switch (StudentGrade[i]) {
case 'A':
GradeSum += 5;
break;
case 'B':
GradeSum += 4;
break;
case 'C':
GradeSum += 3;
break;
case 'D':
GradeSum += 2;
break;
case 'E':
GradeSum += 1;
break;
case 'F':
GradeSum += 0;
break;
default:
break;
}
}
ClassGradePointAvg = GradeSum
/ ((sizeof(StudentGrade) - sizeof(StudentGrade[0])) + 1);
std::cout << "Class Grade Point Average is : " << ClassGradePointAvg
<< std::endl;
}
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

void dummy()
{
std::cout << "HI" << std::endl;
std::cout << "HI this is Maaruf" << std::endl;
}
118 changes: 118 additions & 0 deletions Week_3/AcceleratedC++_3-5/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Accelerated C++ 3-5
## Overview

C++ project that keeps track of student names computes grades based on their marks.

## Standard install via command-line
```
git clone -b maarufvazifdar_117509717 https://github.com/maarufvazifdar/cpp-boilerplate.git

cd <path to repository>
mkdir build
cd build
cmake ..
make
Run tests: ./test/cpp-test
Run program: ./app/AcceleratedC++_3-5
```

## Building for code coverage (for assignments beginning in Week 4)
```
sudo apt-get install lcov
cmake -D COVERAGE=ON -D CMAKE_BUILD_TYPE=Debug ../
make
make code_coverage
```
This generates a index.html page in the build/coverage sub-directory that can be viewed locally in a web browser.

## Working with Eclipse IDE

## Installation

In your Eclipse workspace directory (or create a new one), checkout the repo (and submodules)
```
mkdir -p ~/workspace
cd ~/workspace
git clone --recursive -b maarufvazifdar_117509717 https://github.com/maarufvazifdar/cpp-boilerplate.git

```

In your work directory, use cmake to create an Eclipse project for an [out-of-source build] of cpp-boilerplate

```
cd ~/workspace
mkdir -p AcceleratedC++_3-5
cd AcceleratedC++_3-5
cmake -G "Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug -D CMAKE_ECLIPSE_VERSION=4.7.0 -D CMAKE_CXX_COMPILER_ARG1=-std=c++14 ../cpp-boilerplate/Week_3/AcceleratedC++_3-5
```

## Import

Open Eclipse, go to File -> Import -> General -> Existing Projects into Workspace ->
Select "AcceleratedC++_3-5" directory created previously as root directory -> Finish

# Edit

Source files may be edited under the "[Source Directory]" label in the Project Explorer.


## Build

To build the project, in Eclipse, unfold AcceleratedC++_3-5 project in Project Explorer,
unfold Build Targets, double click on "all" to build all projects.

## Run

1. In Eclipse, right click on the AcceleratedC++_3-5 in Project Explorer,
select Run As -> Local C/C++ Application

2. Choose the binaries to run (e.g. AcceleratedC++_3-5, cpp-test for unit testing)


## Debug


1. Set breakpoint in source file (i.e. double click in the left margin on the line you want
the program to break).

2. In Eclipse, right click on the AcceleratedC++_3-5 in Project Explorer, select Debug As ->
Local C/C++ Application, choose the binaries to run (e.g. AcceleratedC++_3-5).

3. If prompt to "Confirm Perspective Switch", select yes.

4. Program will break at the breakpoint you set.

5. Press Step Into (F5), Step Over (F6), Step Return (F7) to step/debug your program.

6. Right click on the variable in editor to add watch expression to watch the variable in
debugger window.

7. Press Terminate icon to terminate debugging and press C/C++ icon to switch back to C/C++
perspetive view (or Windows->Perspective->Open Perspective->C/C++).


## Plugins

- CppChEclipse

To install and run cppcheck in Eclipse

1. In Eclipse, go to Window -> Preferences -> C/C++ -> cppcheclipse.
Set cppcheck binary path to "/usr/bin/cppcheck".

2. To run CPPCheck on a project, right click on the project name in the Project Explorer
and choose cppcheck -> Run cppcheck.


- Google C++ Sytlehttps://github.com/maarufvazifdar/cpp-boilerplate.git
1. In Eclipse, go to Window -> Preferences -> C/C++ -> Code Style -> Formatter.
Import [eclipse-cpp-google-style][reference-id-for-eclipse-cpp-google-style] and apply.

2. To use Google C++ style formatter, right click on the source code or folder in
Project Explorer and choose Source -> Format

[reference-id-for-eclipse-cpp-google-style]: https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-cpp-google-style.xml

- Git

It is possible to manage version control through Eclipse and the git plugin, but it typically requires creating another project. If you're interested in this, try it out yourself and contact me on Canvas.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ set(CMAKE_CXX_STANDARD 14)

add_subdirectory(app)
add_subdirectory(test)
add_subdirectory(vendor/googletest/googletest)
Binary file added Week_3/AcceleratedC++_4-5/UML_diagram.pdf
Binary file not shown.
Loading