- Joined
- Oct 2, 2006
- Messages
- 1
- Reaction score
- 0
Well I'm writing a school project and my compiler keeps telling me a line is wrong with the errors ".class expected" and ")" expected. We are required to use the Gregorian calendar and so far this is what I have.
package craijwlab2;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
public static void main(String[] args) {
GregorianCalendar cal = new GregorianCalendar();
cal.add(Calendar.MONTH, 1);
JOptionPane.showMessageDialog(null, "Todays date is "+cal.get(Calendar.MONTH)+"/"+cal.get(Calendar.DATE)+"/"+cal.get(Calendar.YEAR));
String birthMonth;
birthMonth = JOptionPane.showInputDialog("Which month number were you born in?:");
int month = Integer.parseInt(birthMonth);
String dayOfBirth;
dayOfBirth = JOptionPane.showInputDialog("Which day of the month were you born?:");
int date = Integer.parseInt(dayOfBirth);
String birthYear;
birthYear= JOptionPane.showInputDialog("What is the year of your birth:");
int year = Integer.parseInt(birthYear);
**GregorianCalendar birthday= new GregorianCalendar(int month, int date, int year);**
JOptionPane.showInputDialog("So your birthday is "+(birthday)+"?");
}
}
The line with the stars around it is the one with the errors but maybe I'm missing something in the code? Thanks in advance. The aim of this project is to get the information from the user about their birthday and then use it and today's date to get their age.
package craijwlab2;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
public static void main(String[] args) {
GregorianCalendar cal = new GregorianCalendar();
cal.add(Calendar.MONTH, 1);
JOptionPane.showMessageDialog(null, "Todays date is "+cal.get(Calendar.MONTH)+"/"+cal.get(Calendar.DATE)+"/"+cal.get(Calendar.YEAR));
String birthMonth;
birthMonth = JOptionPane.showInputDialog("Which month number were you born in?:");
int month = Integer.parseInt(birthMonth);
String dayOfBirth;
dayOfBirth = JOptionPane.showInputDialog("Which day of the month were you born?:");
int date = Integer.parseInt(dayOfBirth);
String birthYear;
birthYear= JOptionPane.showInputDialog("What is the year of your birth:");
int year = Integer.parseInt(birthYear);
**GregorianCalendar birthday= new GregorianCalendar(int month, int date, int year);**
JOptionPane.showInputDialog("So your birthday is "+(birthday)+"?");
}
}
The line with the stars around it is the one with the errors but maybe I'm missing something in the code? Thanks in advance. The aim of this project is to get the information from the user about their birthday and then use it and today's date to get their age.
Last edited: