Just started today... need help. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Just started today... need help.

DemonsguileDemonsguile Posts: 2Member
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 [u][b]explanation[/b][/u] 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; [b]<--- Getting an error here: { expected after this token.[/b]

// 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","2007","2006","2005","2004","2003","2002",

//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


} [b]<--- Syntax error: insert { to complete Class body.[/b]

Sign In or Register to comment.