Overview

The purpose of this assignment is to ensure that all students are able to create, compile, and run Java programs in a terminal using Windows Subsystem for Linux.

Pre-Lab Work

Before coming to lab, watch this video and follow the steps shown to install Windows Subsystem for Linux (WSL) onto your machine and get it set up to run Java programs.

Part I

The following program asks users for the number of credits they are taking and the number of hours they plans to study each week. The program calculates the recommended number of hours to study based on the number of credits and compares that to the student's plan.

/* 
 * Course: CSC-1110
 * Fall 2025
 * Lab 1 - First Program
 * Name: Dr. Chris Taylor
 * Created: 06/10/24
 */

import java.util.Scanner;

/**
 * Class containing the entire program for lab 1 in Fall 2025 CSC-1110 course. 
 * @author taylor
 * @version 2024-06-10
 */
public class StudyTime {

    /**
     * Simple program to determine help set study expectations for a new
     * college student.
     * @param args ignored
     */
    public static void main(String[] args) {
        // Create a "reference variable"/object to gather data
        // from the keyboard
        Scanner in = new Scanner(System.in);
        
        // Request data from the user
        System.out.print("Enter the number of credits you are taking this term: ");
        int creditsTaken = in.nextInt();
        System.out.print("Enter the number of hours you plan to spend studying each week: ");
        int plannedHours = in.nextInt();

        // Calculate recommended hours of study
        int recommendedHoursLow = creditsTaken * 2;
        int recommendedHoursHigh = creditsTaken * 3;

        System.out.println("You are taking " + creditsTaken 
                 + " credits this term and plan to study " + plannedHours 
                 + " hours per week.");

        System.out.print("You plan to study ");
        if(plannedHours < recommendedHoursLow) {
            System.out.print("less than");
        } else if(plannedHours > recommendedHoursHigh) {
            System.out.print("more than");
        } else {
            System.out.print("in the range of");
        }
        System.out.println(" the recommended " + recommendedHoursLow + " - "
                 + recommendedHoursHigh + " hours per week.");

    }

}

Follow along as your instructor demonstrates how to set up WSL and install Java. Then copy the above code into the text editor and save it as StudyTime.java. Compile and run the program using the javac and java commands.

Part II

Once you have successfully compiled and run the program, create a new class called TruthsAndLie and write a program that displays two true statements about yourself and one lie about yourself. The program you write should be much less complicated than the sample program above since you will not require user input or do any calculations. Note: your program should just print the three statements. It should not identify which statements are true and which statement is a lie.

Select a partner (or be assigned one by your instructor), introduce yourselves and demonstrate your working programs. If you need help getting your program to work, ask your partner for help. If your partner needs help getting their program to work, assist them. Once both of your programs compile and run successfully, have your partner guess which of your statements is a lie.

Record both of your names and indicate how many guesses it took to guess the lie. For example, if Jane Dough and Jon D'oh were partners and Jon guessed Jane's lie on the first guess and Jane guessed Jon's lie on the second guess, your paper should look something like this:

NameNumber of guesses
Jane Dough2 guesses
Jon D'oh1 guess

Acknowledgement

This laboratory assignment was developed by Dr. Chris Taylor.

Lab Deliverables (due at the end of week 1 lab)

Make sure you follow any additional requirements and submission instructions for your instructor.