Java day counting project

I'm new to java and taking this beginner course..

Page 1 of 1

1 Replies - 1740 Views - Last Post: 02 July 2009 - 01:52 PM Rate Topic: -----

#1 mssbrightside25   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-June 08

Java day counting project

Post icon  Posted 02 July 2009 - 01:46 PM

I keep getting this: "73: unexpected type" when compiling my code. After I do a line I compile it so I can see where any errors are and THEN I keep going; this error however, it postponing me :unsure:
I also would like any help with this program. I'm supposed to be able to pick between two years and the program should count how many days were passed or are in between the two years. (i.e.--Years: ((7 4 1776) & (1 1 1987)); Answer: 76882 days.

import java.util.*;
public class DiffinDates
{
	public static void main (String[] args)
	{
		Scanner scan = new Scanner(System.in);
		
		int m;	//month
		int d;	//day
		int y;	//year
		boolean leapYear;	//to check if it's a leap year
		int daysInMonth;	  //if leap year, either 28 or if not leap year, 29
		long r;   //result  
		
		System.out.println("Please type in your dates using 'mm dd yyyy' numbers only: ");
		System.out.print("M: ");
		m = scan.nextInt(); 
		System.out.print("D: ");
		d = scan.nextInt();
		System.out.print("Y: ");
		y = scan.nextInt();
		System.out.print("M: ");
		m = scan.nextInt(); 
		System.out.print("D: ");
		d = scan.nextInt();
		System.out.print("Y: ");
		y = scan.nextInt();

	
		if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
		{
			daysInMonth = 31;
		}
		else if(m==4||m==6||m==9||m==11)
		{
			daysInMonth = 30;
		}
		else
		{
			m = 2;	
		}
		
		if(y % 400 == 0)
		{
			leapYear = true;
		}
		else if((y % 4 == 0) && (y % 100 != 0))
		{
			leapYear = true;
		}
		else
		{
			leapYear = false;
		}
		
		if(leapYear)
		{	
			daysInMonth = 29;
		}	
		else
		{	
			daysInMonth = 28;
		}	
		
		r = (m + d + y + daysInMonth)
		
								System.out.println("Data: " + m + " " + d + " " + y)
		System.out.println("The total days between your years picked are: " + result);
		System.out.println("This program was written by Mssbrightside25.");
		
	}
}


This post has been edited by mssbrightside25: 02 July 2009 - 01:47 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Java day counting project

#2 xclite   User is offline

  • I wrote you an code
  • member icon


Reputation: 1528
  • View blog
  • Posts: 4,448
  • Joined: 12-May 09

Re: Java day counting project

Posted 02 July 2009 - 01:52 PM

Can you put a comment near whichever line is 73?

Edit: is 73 the last line?

System.out.println("The total days between your years picked are: " + result);



Should be
System.out.println("The total days between your years picked are: " + r);


This post has been edited by xclite: 02 July 2009 - 01:51 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1