Re: Help with three lines
Please post the full text of the error messages.
The little bits and pieces you posted has left out important information.
Please edit the code and properly format it. Nested statements should be indented.
Too many statements state in the first column making the code hard to read and understand. The }s should not be in a column one beneath the other.
Fixing the formatting will make it easier to see some of the errors.
Re: Help with three lines
oh sorry i did it after i posted it:
Code :
import java.util.Scanner;
public class GtoJ {
public static void main(String[] args) {
int mm, dd,yy;
int [] mod= {31,28,31,30,31,30,31,31,30,31,30,31};
Scanner Sel= new Scanner (System.in);
System.out.println (" Input Year:");
yy= Sel.nextInt( );
if (yy%400==0||(yy%100!=0&&%yy%4==0))
{mod [1]=29;}
System.out.print("1 for GtoJ (),2 for J to G ()");
int s= Sel.nextInt();
if (s==1)
{
int m = Sel.nextInt ();
int d = Sel.nextInt ();
System.out.println ("Input 2 digit number:");
GtoJ (m,d,mod);
else {System.out.println ("Input 3 digit Julian:");
int ddd= Sel.nextInt ();
JtoG (ddd,mod);
}
}
}
For the errors i got this:For the line:
if (yy%400==0||(yy%100!=0&&%yy%4==0))
illegal start of expression
else {System.out.println ("Input 3 digit Julian:");
-else without 'if'
JtoG (ddd,mod); & GtoJ (m,d,mod);
-Cannot find symbol
symbol method: GtoJ (int, int,int [])
location class GtoJ
Surrounded with
...introduce
Those are the errors within the program and once i run it:
run:
Input Year:
1992
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - illegal start of expression
at gtoj.GtoJ.main(GtoJ.java:13)
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
Re: Help with three lines
The formatting is still poor. It is hard to read code when the {s are all over the place.
Also the error messages are a mess and hard to read. They don't include the line number where the error happens.
Here is a sample of an error message from the javac command:
Code :
TestSorts.java:138: cannot find symbol
symbol : variable var
location: class TestSorts
var = 2;
^
What symbol is not found in the error message you posted?
4 Attachment(s)
Re: Help with three lines
oh, i dont know if this is better i added a screen shot
I fixed the error in the 'If' statement its only lines 22,23,25 that i dont understand im not sure what to put infront of the GtoJ and JtoG
Attachment 1774
These are the errors with those lines:
Attachment 1775Attachment 1776Attachment 1777
Re: Help with three lines
Sorry, I can't read those images. Can you copy and paste the text of the error messages. See post#4 for a sample of what the output from the javac compiler gives.
The poor formatting is hiding problems in the code.
Re: Help with three lines
oh i dont think it does that im netbeans, i have a mac
Re: Help with three lines
The poor formatting is hiding problems in the code.
Sorry, I don't know how to execute the java compiler on a mac.
Re: Help with three lines
I looked at your code; you have an extra modulus operator in the conditions of your if statement, here:
if (yy%400==0||(yy%100!=0&& % yy%4==0))
--- Update ---
Your "else without if" error is because you are missing a closing curly brace before the else.
Actually, you have curly braces all over place. Re-code your program with proper formatting and you will be able to see your errors.
Re: Help with three lines
I don't use Macs, so I cant help you there. As for your code, it's difficult to read because you have { and } placed very awkwardly. Keep in mind, with NetBeans, it will show you which braces open and close each other based on how you wrote it and if there are too many, however, it does not check whether there are logical errors resulting from misuse of braces. From one of your screenshots, on lines 22 and 25 have several errors. First, you're trying to pass variables into a class instead of into a method. Second, you're trying to pass an integer array as an integer. Third, the methods GtoJ and JtoG do not exist anywhere in the code you provided, which is why the compiler is giving you those errors for it.
Although it's not an error, on line 8, you never do anything with 2 of the 3 int variables. What is their purpose in your code? If they have none, delete them. Also, what are you trying to use the array for because you only have one of its elements replaced by 29?
Adjust the formatting and it's possible you'll find more errors. A chunk of your code needs to be re-written, so fix the other errors that are easier to handle first.