OverviewThe purpose of this assignment is to ensure that all students are able to create, compile, and run Java programs within the Eclipse Integrated Development Environment (IDE). DetailsThe 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-002
* Term: Fall 2009
* Assignment: Lab 1
* Author: Chris Taylor
* Date: 09/14/09
*/
package taylor;
import java.util.Scanner;
/**
* Class containing the entire program for lab 1 in fall 2009
* SE-1011-002 course.
* @author taylor
*
*/
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 Eclipse. Then paste the above code into the text editor window of Eclipse. Demonstrate to your instructor that you can compile and run the program. Lab Deliverables (due at the end of week 2 lab)Each student must demostrate compiling and running the program on their laptop. AcknowledgmentThis laboratory assignment was developed by Dr. Chris Taylor. |