Bodybuilding.com Information Motivation Supplementation
in:

    The World’s #1 Bodybuilding And Fitness Forum - Save Up To 50% Off Retail Prices In Our Bodybuilding.com Store!

Reply
Results 1 to 8 of 8
  1. #1
    IFBB BRO GetHugeBrah's Avatar
    Join Date: Jan 2011
    Age: 21
    Stats: 5'9", 201 lbs
    Posts: 12,348
    Rep Power: 8710
    GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000)
    Visit GetHugeBrah's BodySpace
    GetHugeBrah is offline

    JAVA brahs here??????????? Need help fixing an error!

    Do not understand why this code will not work:

    Code:
            import java.util.Scanner;
            import java.io.*;
             
            public class diffsInDates
            {
            	public static void main(String[] args) throws IOException
            	{
            		int m1= 0 , d1= 0 , y1= 0 , m2= 0 , d2= 0, y2= 0 ;
    
             
            		for(int i = 0 ; i < 6 ; i++)// to keep loop active until all data is scanned.
            		{
             
            			m1 = Scan.nextInt(); // integers that are scanned in.
            			d1 = Scan.nextInt();
            			y1 = Scan.nextInt();
            			m2 = Scan.nextInt();
            			d2 = Scan.nextInt();
            			y2 = Scan.nextInt();
             
            			System.out.println("Total number of days between dates entered are: " + x(m1, m2, d1, d2, y1, y2) );
            		}
            	}	
            		public static int x (int m1, int m2, int d1, int d2, int y1, int y2)
            		{
            			int result = 0;
            			int result1 = 0;
            			int result2 = 0;
             
            			if( m1 == m2 && y1 == y2)
            			{ 										// counts days if year and month are the same.
            			result = d2 - d1 +1;
            			}
             
            			else if ( y1 == y2 )
            			{
            			result = daysInMonth( m2 , y2 ) - d1 + 1;
            			}
             
            			for(int i = m1; i < m2 ; i++) // counts months
            			{
            				result1 += daysInMonth( m2 , y2 );
            			}
             
            			for (int i = y1; i < y2; i++)
            			{ 											// counts years
            			result2 += daysInYear( y2 );
            			}
             
            			result += result1 + result2;
            			return result;
            			}
             
            		//methods
             
            		public static boolean isLeap(int year) // to find if it is a leap year
            		{
            			if( year % 400 == 0)
            				return true;
             
            			else if( year % 4 == 0 && year % 100 != 0)
            					 return true;
             
            			else return false;
            		}
             
             
            		public static int daysInMonth( int month , int year) // to find days in the month
            		{
            			int leapMonth;
             
            			if (isLeap(year)== true)
            			{
            				leapMonth = 29;
            			}
            			else 
            			{
            				leapMonth = 28;
            			}
             
            			switch(month)
            			{
            				case 4:  
            				case 6:	
            				case 9:	
            				case 11: return 30;
            				case 1:
            				case 3:
            				case 5:	
            				case 7:	
            				case 8:	
            				case 10:	
            				case 12: return 31;
            				case 2: return leapMonth;
            			}
            			return 28;
            		}
             
            		public static int daysInYear(int year) // to find the days in the year, leap or not.
            		{
            			if( isLeap(year)){
            		   	return 366;
            				}
            			else{
            			 return 365;
            			 }
            		}
            }
    Its giving me:

    ----jGRASP exec: javac -g diffsInDates.java

    diffsInDates.java:15: error: cannot find symbol
    m1 = Scan.nextInt(); // integers that are scanned in.
    ^
    symbol: variable Scan
    location: class diffsInDates
    diffsInDates.java:16: error: cannot find symbol
    d1 = Scan.nextInt();
    ^
    symbol: variable Scan
    location: class diffsInDates
    diffsInDates.java:17: error: cannot find symbol
    y1 = Scan.nextInt();
    ^
    symbol: variable Scan
    location: class diffsInDates
    diffsInDates.java:18: error: cannot find symbol
    m2 = Scan.nextInt();
    ^
    symbol: variable Scan
    location: class diffsInDates
    diffsInDates.java:19: error: cannot find symbol
    d2 = Scan.nextInt();
    ^
    symbol: variable Scan
    location: class diffsInDates
    diffsInDates.java:20: error: cannot find symbol
    y2 = Scan.nextInt();
    ^
    symbol: variable Scan
    location: class diffsInDates
    6 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    LOOKING FOR A NEW COMPANY TO REPRESENT
    ***Greek/Ancient Egyptian Genetics***
    **Huge Arms Crew**
    ISSA Personal Trainer
    LIKE MY PAGE BRAHS: FACEBOOK.COM/GETHUGEBRAH
    Atlanta, GA
    Reply With Quote

  2. #2
    IFBB BRO GetHugeBrah's Avatar
    Join Date: Jan 2011
    Age: 21
    Stats: 5'9", 201 lbs
    Posts: 12,348
    Rep Power: 8710
    GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000)
    Visit GetHugeBrah's BodySpace
    GetHugeBrah is offline
    If anyone is wondering what the problem im trying to solve, its:

    Write a program to accept any two dates in the form of month, day, and year (8 23 2000), separated by spaces, and calculate the total number of days that has elapsed between the two dates, inclusive of the beginning and ending days. Remember that leap year is a year divisible by 4, except for centennial years, which must be divisible by 400, such as 1600 or 2000 (1800 is not a leap year). You can test your program with any typed in dates but it must finally run with the data shown below. System output on the screen is acceptable.

    DATA: ANSWERS
    7 4 1776 1 1 1987 (76882)
    2 1 1983 3 3 1984 (397)
    4 7 1983 11 4 1983 (???)
    7 3 1983 7 20 1983 (18)
    12 29 1990 12 31 1992 (???)
    your birthdate to due date (?)

    1. Consider using the long data type for dayCounter
    2. The program must continue running until all the data is processed – use a loop 1 to 6 or a while (month != -1) or while (!fin.eof()) - choose your own end of data technique.
    3. Use if statements, switch statements, and loops to solve this problem. Do not use the Gregorian date method!
    LOOKING FOR A NEW COMPANY TO REPRESENT
    ***Greek/Ancient Egyptian Genetics***
    **Huge Arms Crew**
    ISSA Personal Trainer
    LIKE MY PAGE BRAHS: FACEBOOK.COM/GETHUGEBRAH
    Atlanta, GA
    Reply With Quote

  3. #3
    Registered User LAballin24's Avatar
    Join Date: Jul 2009
    Age: 26
    Posts: 4,858
    Rep Power: 3158
    LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000) LAballin24 must be a mod! Best possible rank! (+1000000)
    Visit LAballin24's BodySpace
    LAballin24 is offline
    Where is your scanner?
    Reply With Quote

  4. #4
    Protein Hacker mehdi84's Avatar
    Join Date: Dec 2007
    Location: Massachusetts, United States
    Age: 29
    Stats: 162 lbs
    Posts: 9,014
    BodyPoints: 2377
    Rep Power: 4997
    mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000) mehdi84 must be a mod! Best possible rank! (+1000000)
    Visit mehdi84's BodySpace
    mehdi84 is offline
    Because if it were easy, I wouldn't be interested.

    God has a better plan for my life, than I do, for my own.

    Go, weave your snares with logic and design. The speed of my flight will take your breath away. - Mirza Ghalib

    === 228 Crew ===
    Reply With Quote

  5. #5
    IFBB BRO GetHugeBrah's Avatar
    Join Date: Jan 2011
    Age: 21
    Stats: 5'9", 201 lbs
    Posts: 12,348
    Rep Power: 8710
    GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000)
    Visit GetHugeBrah's BodySpace
    GetHugeBrah is offline
    Originally Posted by LAballin24 View Post
    Where is your scanner?
    Originally Posted by mehdi84 View Post
    Not sure what you guys mean, should I put int i = scan.nextInt(); up top?

    About to read my Java book for a couple of hrs, hopefully I can understand this sht
    LOOKING FOR A NEW COMPANY TO REPRESENT
    ***Greek/Ancient Egyptian Genetics***
    **Huge Arms Crew**
    ISSA Personal Trainer
    LIKE MY PAGE BRAHS: FACEBOOK.COM/GETHUGEBRAH
    Atlanta, GA
    Reply With Quote

  6. #6
    Registered User jorts150's Avatar
    Join Date: Sep 2011
    Stats: 5'7", 155 lbs
    Posts: 123
    Rep Power: 31
    jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000) jorts150 has much to be proud of. One of the best! (+20000)
    Visit jorts150's BodySpace
    jorts150 is offline
    Scanner Scan = new Scanner( System.in );

    you need to put that up top (probably under where you defined your integers) in order to initialize the scanner and accept user input
    Reply With Quote

  7. #7
    IFBB BRO GetHugeBrah's Avatar
    Join Date: Jan 2011
    Age: 21
    Stats: 5'9", 201 lbs
    Posts: 12,348
    Rep Power: 8710
    GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000) GetHugeBrah must be a mod! Best possible rank! (+1000000)
    Visit GetHugeBrah's BodySpace
    GetHugeBrah is offline
    Originally Posted by jorts150 View Post
    Scanner Scan = new Scanner( System.in );

    you need to put that up top (probably under where you defined your integers) in order to initialize the scanner and accept user input
    Thanks, this sht is incredibly hard IMO for a beginner, currently reading my book which honestly I am very behind on the reading.
    LOOKING FOR A NEW COMPANY TO REPRESENT
    ***Greek/Ancient Egyptian Genetics***
    **Huge Arms Crew**
    ISSA Personal Trainer
    LIKE MY PAGE BRAHS: FACEBOOK.COM/GETHUGEBRAH
    Atlanta, GA
    Reply With Quote

  8. #8
    Registered User AL0's Avatar
    Join Date: Jul 2011
    Age: 22
    Posts: 636
    Rep Power: 191
    AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000) AL0 has a reputation beyond repute. Second best rank possible! (+100000)
    AL0 is offline
    Decent.

    Only thing I would say about that is don't have so many returns and else returns for you methods. Have one. For boolean make a boolean variable call it leapYear or whatever then have leapYear = false or leapYear = true and then have it return leapYear. It doesn't change the program, but it's a good habit for good coding. Do this for any method.
    Reply With Quote

Reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home Store Products Careers Help Contact Us Terms of Use Checkout