Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

Just started today... need help.

$
0
0
I decided to start to learn to program, and I've already gone through a few tutorials. But, at this point the knowledge hasn't sunk in. I was hoping to get some help in base knowledge. I would appreciate an explanation of what is wrong... not a code fix.

I've given myself the task of writing a program with the following goals:
1. How many days have you been alive?
2. How many hours have you been alive?
3. How many minutes have you been alive?
4. How many seconds have you been alive?
5. What milestones have you passed?
a. 16 - Driver's License
b. 18 - Adult
c. 21 - Alcohol
d. 25 - Cheaper insurance
e. 35 - Can be president.
f. 55 - Senior citizen
g. 65 - Retirement
h. 100 - Centennial

I stole (borrowed?) some code from a website (I would give proper credit to the author, but I lost the website) and have been trying to manipulate it to gain some understanding of how things work in Java.

This is where I'm at:
package CompareDates;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;

public class CompareDates
{
	// Declare variables
	int month;
	int day;
	int year;  <--- Getting an error here: { expected after this token.

	// Instantiate variables
	month = 0;
	day   = 0;
	year  = 0;
			
	// Define the contents of the dropdowns.
	String [] monthContent={"January", "February", "March", "April", "May", "June", "July", "August",
			"September", "October", "November", "December"};
	String [] dayContent={"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
			"15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
			"30", "31"};
	String [] yearContent={"2012","2011","2010","2009","2008","2
007","2006","2005","2004","2003","2002",
			"2001","2000","1999","1998","1997","1996","1995","
1994","1993","1992","1991","1990","1989",
			"1988","1987","1986","1985","1984","1983","1982","
1981","1980","1979","1978","1977","1976",
			"1975","1974","1973","1972","1971","1970","1969","
1968","1967","1966","1965","1964","1963"};

		//Define the dropdowns.
	JComboBox monthComboBox=new JComboBox(monthContent);
	JComboBox dayComboBox=new JComboBox(dayContent);
	JComboBox yearComboBox=new JComboBox(yearContent);
	
		//Create the button.
	JButton button=new JButton("Click to analyze.");
	
		//Create the window frame.
	JFrame frame=new JFrame("Compare two dates");
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

} <--- Syntax error:  insert { to complete Class body.




Viewing all articles
Browse latest Browse all 2703

Trending Articles