Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

36 total results found

Setup and Links

Intro to Java

You can view the lecture slides and lab files here. Class Materials

Cheat Sheet

Intro to Java

Java Coding Standards Always include class documentation Class names start with upper-case letters Variable names start with lower-case letters Align { and matching } in same column Indent methods and statements Use meaningful variable names Use camelNotation...

L01 - Visual Studio Code (VS Code) Lab

Intro to Java Labs

Install Visual Studio Code from FIRST, you will need their version with WPILib. Link In this exercise, we'll use an IDE to enter and execute a Java program. Start and the following window will appear: Select the File > Open and either open a folder to use as...

L02 - Soda Can Lab

Intro to Java Labs

In this exercise, we're going to implement a class SodaCan. This class has a constructor that accepts the height and radius of the soda can as parameters. We'll supply the methods getVolume and getSurfaceArea. We'll also write a SodaCanTest class to test our S...

L03 - Coupons

Intro to Java Labs

A supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you will get a coupon worth eight percent of that amount. The following table shows the percent used to calculate the coupon awarded for different...

L04 - Iteration Lab - Part 1 - Nested For Loops

Intro to Java Labs

We can determine if a number is even or odd by checking the remainder after dividing the number by 2: if (number % 2 == 0) System.out.println(number + " is even"); else System.out.println(number + " is odd"); Create a class named Patterns that uses th...

L04 - Iteration Lab - Part 2 - The Three Loops

Intro to Java Labs

Enter the following program and fill in the missing pieces so that the three different styles of loops compute the sum of numbers. public class Loops { public static void main(String[] args) { //sum the numbers from 1 to 5 using a for loop int sum ...

L05 - Using Arrays

Intro to Java Labs

Create a new class named UsingArrays. Using the lecture slides as a guide, declare and initialize an array of four integers that contains the values 3, 7, 13, and 18. Using a for loop, display each of the four array values and the square of that value. Sampl...

L06 - Bank Account Lab

Intro to Java Labs

In this lab, we'll implement three classes: BankAccount, CheckingAccount, and BankAccountTest. As we write these classes, we will be taking advantage of Java's inheritance and polymorphism capabilities to make our job easier. BankAccount Class This is the pare...

L07 - Shapes Lab

Intro to Java Labs

In this lab, we'll work with Abstract Classes. Start VS Code. During the lecture we discussed the following classes: Shape – an abstract class Circle – a class that is derived from Shape Ellipse – a class that is also derived from Shape Using the Circle cl...

L08 - Autopilot Interface Lab

Intro to Java Labs

In this lab, there is no main method, we are not running the code, just checking if it compiles without errors. To do that just make sure there are no errors. Fred Finn, ace programmer, has created an interface to ensure programmers who implement airplanes in...

L09 - ReverseIt Lab

Intro to Java Labs

Write a program that reads in a file and writes each line backwards to an output file. Below is a skeleton of the program. Fill in the blanks with the missing code. /** * Reverses each line of an input file and writes it to an output file. * * @author ______ ...

L10 - Runtime Exceptions Lab

Intro to Java Labs

Runtime Exceptions Lab Using the lecture slides as a guide, In a new class, instantiate an array that can hold exactly four integers Using a for loop, prompt the user for an integer and store the value in the array. Repeat this five times (!). Run your progra...

L11 - Designing Exception Types Lab

Intro to Java Labs

In this lab, we'll create our own exception class for the BankAccount class to handle the case where a customer tries to withdraw more money than they have in their account. If you haven't already done so, complete the L06 Bank Account lab. Create an Insuffic...

L12 - Recursion Exercise

Intro to Java Labs

Part A – Fibonacci A recursive algorithm can be very fast. Sometimes it's the only solution to a problem. Sometimes the recursive version of an algorithm has very poor performance compared to an iterative solution. In this part of the exercise, we'll empirical...

L13 - Finite State Machines

Intro to Java Labs

Introduction – Making Change Finite State Machines(FSMs) are a method to organize a system of inputs and outputs into a program that is easy to write, understand, and extend. For example, let's imagine you are writing code for a vending machine to output the ...

L01

Intro to Java Lab Solutions

Test.java /** * Print the Answer to Life, the Universe, Everything. * * @author Brandon * @version 1/1/1990 */ public class Test { static int answer1 = 0; static int answer2; static int theAnswer; public static void main(String[] args) {...

L02

Intro to Java Lab Solutions

SodaCan.java /** * Constructor and methods for a soda can object * * @author Brandon * @version 1/1/1990 */ public class SodaCan { private double r; // soda can radius private double h; // soda can height public SodaCan(double radius, double heigh...

L03

Intro to Java Lab Solutions

Coupons.java import java.util.Scanner; public class Coupons { public static void main(String[] args) { Scanner myScanner = new Scanner(System.in); System.out.print("Please enter the cost of your groceries: "); double amount = Doub...

L04 - Part 1

Intro to Java Lab Solutions

Patterns.java public class Patterns { public static void main(String[] args) { for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if ((i + j) % 2 == 0) System.out.print("X"); ...