Stocks Java Essay

697 Words Feb 24th, 2015 3 Pages
Lab 4-1 Create a Java Program to Stock Class package myjavaproject2;

public class Lab4_1 {

public static void main(String[] args) { // TODO Auto-generated method stub Stock stock = new Stock("ESI", "ITT Technical Institute Inc."); stock.setPreviousClosingPrice(60.0);

// Set current price stock.setCurrentPrice(65.0);

// Display stock info System.out.println("Symbol: " + stock.getSymbol); System.out.println("Name: " + stock.getName); System.out.println("Previous Closing Price: " + stock.getPreviousClosingPrice()); System.out.println("Current Price: " + stock.getCurrentPrice()); System.out.println("Price Change: " +
…show more content…
2001):", "Enter Year", JOptionPane.QUESTION_MESSAGE);

// Convert string into integer int year = Integer.parseInt(yearString);

// Prompt the user to enter month String monthString = JOptionPane.showInputDialog(null, "Enter month in number between 1 and 12:", "Enter Month", JOptionPane.QUESTION_MESSAGE);

// Convert string into integer int month = Integer.parseInt(monthString); // Print calendar for the month of the year printMonth(year, month); JOptionPane.showMessageDialog(null, output); } /** Print the calendar for a month in a year */ static void printMonth(int year, int month) { // Get start day of the week for the first date in the month int startDay = getStartDay(year, month);

// Get number of days in the month int numOfDaysInMonth = getNumOfDaysInMonth(year, month);

// Print headings printMonthTitle(year, month);

// Print body printMonthBody(startDay, numOfDaysInMonth); }

/** Get the start day of the first day in a month */ static int getStartDay(int year, int month) { // Get total number of days since 1/1/1800 int startDay1800 = 3; long

Related Documents