CSCI 200 - Fall 2024
Foundational Programming Concepts & Design

Lab 1A - Math Equation Solver

This lab is due by Wednesday, August 28, 2024, Before Class.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.

Jump To: Rubric Submission


Editing A C++ Source Code File


If you haven't already, be sure to create a new folder Set1/L1A with a file named main.cpp.

main.cpp will contain our program. You can now start typing code. Sweet! Since this is a programming class, not a typing class, copy the following starter code between the:

/* CSCI 200: Lab XX (_INSERT_LAB_HERE_): XXXX (_GIVE_BRIEF_DESCRIPTION_HERE_)
 *
 * Author: XXXX (_INSERT_YOUR_NAME_HERE_)
 *
 * More complete description here...
 */

// The include section adds extra definitions from the C++ standard library.
#include <iostream> // For cin, cout, etc.

// We will (most of the time) use the standard library namespace in our programs.
using namespace std;

// Define any constants below this comment.

// Must have a function named "main", which is the starting point of a C++ program.
int main() {

  /******** INSERT YOUR CODE BELOW HERE ********/

  cout << "Hello world!" << endl; // print Hello world! to the screen

  /******** INSERT YOUR CODE ABOVE HERE ********/

  return 0; // signals the operating system that our program ended OK.
}

Next, edit all places where XXXX appears in your main.cpp file with the appropriate information. When you are done, you can save main.cpp by typing Ctrl + S.


Running your Code (Windows)


To compile and execute your project is a two-step process. Open a terminal, first compile via g++ and then run the resultant executable:

> g++ main.cpp
> .\a.exe
Hello world!
> 

Running your Code (OS X / *nix)


To compile and execute your project is a two-step process. Open a terminal, first compile via g++ and then run the resultant executable:

> g++ main.cpp
> ./a.out
Hello world!
> 

The Iterative Process


Congratulations! You've written, compiled, and run your very first program!

Now that your program is running, we are going to add to the program to perform two calculations. This will be done in two phases, one for each equation.


Equations!


Below are a list of equations provided by previous students. You will write a program to implement two of these equations.

# Major Equation Formula
1 Chemistry Ideal Gas Law Ideal Gas Law P = nRT / V
2 Civil Engineering Average Acceleration Average Acceleration a = x - x0 / (t - t0)2
3 Electrical Engineering Ohm's Law Ohms Law I = V / R
4 Engineering Physics Newton's Law of Universal Gravitational Newton's Law of Universal Gravitational F = Gmemm / r2
5 Math Distance Distance d = square root x2 + y2
6 Math Volume Sphere Volume of a Sphere V = 4/3 pi r 3
7 Mechanical Engineering Deflection Deflection
8 Mechanical Engineering Heat Transfer Heat Transfer Q = h A delta T
9 Mechanical Engineering Stress Stress sigma = F / a
10 Mining Shear Stress Shear Stress
11 Physics Coulomb's Law Coulombs Law

For each equation, you must:

At the end of this lab, your program output should look similar to below (feel free to dress up the messages a bit for this lab):

Enter the acceleration: 4.33
Enter the mass: 9.3
The force is: 40.269
Enter the width: 4
Enter the height: 2
The area is: 8

For now, we will accept the default number of decimal places that are printed to the terminal.

You just went through a short iterative process, or as programmer's say an incremental build. Once you knew you had your program running properly, you made a small change to the program and reran the program to verify the change was correct. Once again, a small change was introduced to the code and the program was run to verify the proper output. You should become very familiar with this process as it will make future projects go smoother if you make small changes at a time.


Grading Rubric


Your submission will be graded according to the following rubric:

PointsRequirement Description
0.70Fully meets specifications
0.15Submitted correctly by Wednesday, August 28, 2024, Before Class
0.15Best Practices and Style Guide followed
1.00Total Points


Lab Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.

Zip together your main.cpp, Makefile file(s) and name the zip file L1A.zip. Upload this zip file to Canvas under L1A.

This lab is due by Wednesday, August 28, 2024, Before Class.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.