There is a more recent offering of this course. This is an archive of the
course which was offered in Fall 2017.
Lab
1
Start Now
Lab 1: First Program
Give a man food, and he can eat for a day. Give a man a job,
and he can only eat for 30 minutes on break.
Lev L. Spiro
## Overview
The purpose of this assignment is to ensure that all students are able
to create, compile, and run Java programs within the [IntelliJ IDEA](http://www.jetbrains.com/idea/) Integrated Development Environment (IDE).
### Prerequisites
* Download and install [Java Development Kit (JDK) 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html).
* Download and install [IntelliJ IDEA](http://www.jetbrains.com/idea/download/index.html). The Community Edition is all you'll need for this course, but you can download the Ultimate Edition and create a [free student account](https://www.jetbrains.com/student/), if you'd like.
## Details
The following program asks the user for the number of hours worked per week,
the number of weeks of vacation per year, and his/her hourly wage. The
program calculates the total amount that the user will earn in a year.
```
/*
* Course: SE-1011
* Term: Fall 2017
* Assignment: Lab 1
* Author: Dr. Chris Taylor
* Date: 09/14/09
* Modified: 06/08/17 - updated for Fall 2017
*/
package taylor;
import java.util.Scanner;
/**
* Class containing the entire program for lab 1 in fall 2017
* SE-1011 course.
* @author taylor
* @version 2017-06-08-1.5
*/
public class Lab1 {
/**
* Simple program to calculate the amount of money a user
* will earn in one year.
* @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 hours worked per week: ");
int hoursWorked = in.nextInt();
System.out.print("Enter the number of weeks of vacation taken: ");
int vacationWeeks = in.nextInt();
System.out.print("Enter your hourly wage (in dollars): ");
double hourlyWage = in.nextDouble();
// Calculate earnings
double yearlyEarnings = hoursWorked * (52 - vacationWeeks)
* hourlyWage;
System.out.println("You will earn $" + yearlyEarnings
+ " in one year.");
}
}
```
Follow along as your instructor demonstrates how to create a project,
package, and class in IntelliJ. Then paste the above code into the text
editor window of IntelliJ. Demonstrate to your instructor that you can
compile and run the program.
## Lab Deliverables (due at the end of week 1 lab)
Each student must demonstrate compiling and running the program on their
laptop.
## Deliverables
Make sure you follow the submission instructions for __YOUR__
instructor.
## Acknowledgement
This laboratory assignment was developed by
[Dr. Chris Taylor](/taylor/).