CSCI 102 - Fall 2023 Fundamentals of Computation

Week 2 Lab

Introduce Yourselves

Get To Know your TA/CP and fellow students

Discuss Lab Sign-in and/or Check-Off

Everyone should be on the sign-in sheet. If not, please let your CP/TA know.

Go Over Policies

Review the lab policies and ensure you understand them.

Github Account Setup

Ensure your Github account is configured correctly so you can perform the in-class exercises. Follow the instructions from HW 1

Variable-Type Review

Walk through these exercises and complete them as a group to review the basic data types described in lecture. Note: To save and check your work, you will need to have setup your Github account as described in HW1.

cpp/cs102/practice3/types1
cpp/cs102/practice3/types2
cpp/cs102/practice3/types3
cpp/cs102/practice3/types4
cpp/cs102/practice3/types5

Vocareum Account Setup

You should have received an e-mail invitation earlier in the week to setup your account on the Vocareum website. To develop your code you can use any text editor/compiler you like, but we realize most of you probably do not have a compiler installed. Thus, we recommend you use the web-based editor and compiler available through Vocareum.

Homeworks on Vocareum

Starting with HW3, all your homework submissions will be via Vocareum. You can write your code in the Vocareum editor (recommended unless you have an editor/compiler installed on your own machine) or upload code you wrote on your own laptop. When you submit your code, some automated tests will be run to verify the basic correctness. Please read through the submission report to ensure your code is on the right track. However, we will run more thorough tests after submission, so just because you passed the submission tests doesn’t mean you’ll get full points. More specifically your HW grades will be based on:

Test your Vocareum Setup

To ensure you feel comfortable using Vocareum, we will walk through a short exercise. When you login to Vocareum you should see an assignment on the left labelled Lab 2. The lab will start you with a skeleton code file. Complete the code file using the solution shown below to convert from seconds to hours (showing any decimal fraction of an hour) and print the number to the screen followed by a newline (without any other text). Though you may not understand the code we want you to familiarize yourself with the Vocareum interface.

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int seconds;
    cout << "Enter the number of seconds you wish to convert to hours." << endl;
    cin >> seconds;

    // Copy or type the remaining code from the lab website
     
    double hours = seconds / 3600.0;
    cout << seconds << " seconds is " << hours << " hours." << endl;
    
    return 0;
}

Once you have written the code, use the Build and Run buttons to compile and run your program, respectively, testing it with various inputs. Then, when you think it is correct, click Submit which will cause some of our own test cases to be run on your code. Ensure the output is correct. If it is not, go back and edit your code and repeat the Build, Run (optional), and Submit process.

Once it is working, go back and change the following line

   double hours = seconds / 3600.0;

to

   double hours = seconds / 3600;

Now click Submit again and notice the error messages that our testing scripts generate. When you submit code for your homeworks you should similarly review the submission reports for these errors to determine if your code may have an error. If you are unsure why the change above began to cause errors you can ask your TA! Once you are comfortable with the submission review process, you can change your code back to 3600.0 (or any other method that ensures at least one input to the division is a double).

Q&A on Material

Discuss any questions regarding types and expressions.

Open-ended Help

Any students with questions may stay after to get help! Those without questions may leave.