Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2928 > unrolled thread
| Started by | Isaac Chan <isaacchanszelong@gmail.com> |
|---|---|
| First post | 2014-03-24 03:32 -0700 |
| Last post | 2014-03-25 15:12 -0700 |
| Articles | 10 — 6 participants |
Back to article view | Back to comp.lang.java.help
Help Isaac Chan <isaacchanszelong@gmail.com> - 2014-03-24 03:32 -0700
Re: Help Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-24 08:36 -0400
Re: Help Joerg Meier <joergmmeier@arcor.de> - 2014-03-24 14:00 +0100
Re: Help Roedy Green <see_website@mindprod.com.invalid> - 2014-03-25 08:16 -0700
Re: Help Roedy Green <see_website@mindprod.com.invalid> - 2014-03-26 17:50 -0700
Re: Help Isaac Chan <isaacchanszelong@gmail.com> - 2014-03-25 06:34 -0700
Re: Help Isaac Chan <isaacchanszelong@gmail.com> - 2014-03-25 06:54 -0700
Re: Help Roedy Green <see_website@mindprod.com.invalid> - 2014-03-25 08:17 -0700
Re: Help Knute Johnson <eternal@knutejohnson.com> - 2014-03-25 08:55 -0700
Re: Help Lew <lewbloch@gmail.com> - 2014-03-25 15:12 -0700
| From | Isaac Chan <isaacchanszelong@gmail.com> |
|---|---|
| Date | 2014-03-24 03:32 -0700 |
| Subject | Help |
| Message-ID | <803c64a0-66c7-48b8-b9d2-de5520db66a3@googlegroups.com> |
Anyone knowing what is happening below?
It keeps bumping out the <identifier> expected error.
import java.util.Scanner;
class IngeniusXD
{Scanner scn = new Scanner(System.in);
private String Simplify(String cal ,char st ,char nd ,char new)
{for (int i = 0;i < cal.length() -1; i++)
{if ((cal.charAt(i) == st) || (cal.charAt(i + 1) == nd))
{cal = cal.substring(0 ,i - 1) + new + cal.substring(i + 2);}
else if ((cal.charAt(i) == nd) || (cal.charAt(i + 1) == st))
{cal = cal.substring(0 ,i - 1) + new + cal.substring(i + 2);}}
return cal;}
public String Simplify_General(String cal)
{cal = Simplify(cal ,'+' ,'-' ,'-');
cal = Simplify(cal ,'-' ,'-' ,'+');
cal = Simplify(cal ,'+' ,'+' .'+');
return cal;}
public void Simplify_Test()
{System.out.println("Simplify_Test:Input mathematical sentence.");
cal = scn.next();
cal = Simplify_General(cal);
System.out.println("Simplify_Test:Output=");}
public static void main(String[] args)
{SimplifyTest();}}
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2014-03-24 08:36 -0400 |
| Message-ID | <lgp8sk$vls$1@dont-email.me> |
| In reply to | #2928 |
On 3/24/2014 6:32 AM, Isaac Chan wrote:
> Anyone knowing what is happening below?
> It keeps bumping out the <identifier> expected error.
For future reference: It would have been helpful if you'd
pointed out which line provoked the error message. It would
also be a good idea to quote the *exact* and *complete* text
of error messages that puzzle you; the fact that you're puzzled
proves you don't know which bits are safe to omit.
Oh, yeah: Adopt a more reasonable formatting style. If
this sample had been a few lines longer I'd have just said
"Too much bother" and skipped it. But I'm in a good mood
today, so ...
There are a *lot* of things wrong with your code, but the
immediate issue the compiler objects to is
> private String Simplify(String cal ,char st ,char nd ,char new)
Take a close look at the name of the rightmost parameter.
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Joerg Meier <joergmmeier@arcor.de> |
|---|---|
| Date | 2014-03-24 14:00 +0100 |
| Message-ID | <1o4h31tsnfjp4$.pe5myl76x0o1$.dlg@40tude.net> |
| In reply to | #2928 |
On Mon, 24 Mar 2014 03:32:44 -0700 (PDT), Isaac Chan wrote:
> Anyone knowing what is happening below?
In addition to what Eric said:
> public void Simplify_Test()
> [...]
> {SimplifyTest();}}
One with, the other without; so that's probably not going to work. It would
also be helpful if you too a look at the Java Code Conventions (easily
googleable). Other than the borderline unreadable formatting, you also make
various mistakes with how you name things that make it hard for anyone
familiar with Java to read your code.
For starters: dont use Names_Like_This but instead NamesLikeThis (this is
called CamelCase). Further, classes should be camel case start with an
uppercase letter (as yours does), but methods, fields and local variables
should all start with lower case names, so it should be simplifyTest and
simplifyGeneral.
Liebe Gruesse,
Joerg
--
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2014-03-25 08:16 -0700 |
| Message-ID | <rb73j958u87g0tr5amog9u7p9p59p4k32s@4ax.com> |
| In reply to | #2930 |
On Mon, 24 Mar 2014 14:00:23 +0100, Joerg Meier <joergmmeier@arcor.de> wrote, quoted or indirectly quoted someone who said : >Java Code Conventions see http://mindprod.com/jgloss/codingconventions.html Unfortunately my server is down. All the computers and UPSs were wiped out by the mother of all power surges. -- Roedy Green Canadian Mind Products http://mindprod.com "A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer." ~ Bill Gates
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2014-03-26 17:50 -0700 |
| Message-ID | <8et6j9h415ot9f989odqrshiath0471qq1@4ax.com> |
| In reply to | #2933 |
On Tue, 25 Mar 2014 08:16:41 -0700, Roedy Green <see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted someone who said : >see http://mindprod.com/jgloss/codingconventions.html > >Unfortunately my server is down. All the computers and UPSs were wiped >out by the mother of all power surges. back in business. Once you clean that up people can read your code. -- Roedy Green Canadian Mind Products http://mindprod.com "A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer." ~ Bill Gates
[toc] | [prev] | [next] | [standalone]
| From | Isaac Chan <isaacchanszelong@gmail.com> |
|---|---|
| Date | 2014-03-25 06:34 -0700 |
| Message-ID | <12d62efc-1dda-445e-9769-a3d3819a2f18@googlegroups.com> |
| In reply to | #2928 |
Thanks a lot.I fix the major problems now.
[toc] | [prev] | [next] | [standalone]
| From | Isaac Chan <isaacchanszelong@gmail.com> |
|---|---|
| Date | 2014-03-25 06:54 -0700 |
| Message-ID | <0c85aacc-55fc-4abf-9560-eb6bb78c9c17@googlegroups.com> |
| In reply to | #2928 |
I have fixed most of the problems.This is supposed to change ++ into + and -- into + and +- into -.Though it compile successfully ,it refuse to function.
I am new to this.Can u guys help me?
import java.util.Scanner;
class IngeniusXD
{Scanner scn = new Scanner(System.in);
private static String Simplify(String cal ,char st ,char nd ,char rep)
{for (int i = 0;i < cal.length() - 100; i++)
{if ((cal.charAt(i) == st) || (cal.charAt(i + 1) == nd))
{cal = cal.substring(0 ,i - 1) + rep + cal.substring(i + 2);}
else if ((cal.charAt(i) == nd) || (cal.charAt(i + 1) == st))
{cal = cal.substring(0 ,i - 1) + rep + cal.substring(i + 2);}}
return cal;}
public static String Simplify_General(String cal)
{cal = Simplify(cal ,'+' ,'-' ,'-');
cal = Simplify(cal ,'-' ,'-' ,'+');
cal = Simplify(cal ,'+' ,'+' ,'+');
return cal;}
public static void Simplify_Test()
{System.out.println("Simplify_Test:Input mathematical sentence");
Scanner scn = new Scanner(System.in);
String cal;
cal = scn.nextLine();
cal = Simplify_General(cal);
System.out.println("Simplify_Test:Output=" + cal);}
public static void main(String[] args)
{Simplify_Test();}}
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2014-03-25 08:17 -0700 |
| Message-ID | <of73j9dqr6k28h3ru15k48nchllakr4rce@4ax.com> |
| In reply to | #2932 |
On Tue, 25 Mar 2014 06:54:31 -0700 (PDT), Isaac Chan <isaacchanszelong@gmail.com> wrote, quoted or indirectly quoted someone who said : > public static String Simplify_General(String cal) You drive people trying to help you crazy if you don't follow the conventions. Methods start with lower case, classes with upper. -- Roedy Green Canadian Mind Products http://mindprod.com "A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer." ~ Bill Gates
[toc] | [prev] | [next] | [standalone]
| From | Knute Johnson <eternal@knutejohnson.com> |
|---|---|
| Date | 2014-03-25 08:55 -0700 |
| Message-ID | <lgs8tq$v63$1@dont-email.me> |
| In reply to | #2932 |
On 3/25/2014 06:54, Isaac Chan wrote:
> I have fixed most of the problems.This is supposed to change ++ into + and -- into + and +- into -.Though it compile successfully ,it refuse to function.
> I am new to this.Can u guys help me?
>
>
> import java.util.Scanner;
> class IngeniusXD
> {Scanner scn = new Scanner(System.in);
> private static String Simplify(String cal ,char st ,char nd ,char rep)
> {for (int i = 0;i < cal.length() - 100; i++)
> {if ((cal.charAt(i) == st) || (cal.charAt(i + 1) == nd))
> {cal = cal.substring(0 ,i - 1) + rep + cal.substring(i + 2);}
> else if ((cal.charAt(i) == nd) || (cal.charAt(i + 1) == st))
> {cal = cal.substring(0 ,i - 1) + rep + cal.substring(i + 2);}}
> return cal;}
> public static String Simplify_General(String cal)
> {cal = Simplify(cal ,'+' ,'-' ,'-');
> cal = Simplify(cal ,'-' ,'-' ,'+');
> cal = Simplify(cal ,'+' ,'+' ,'+');
> return cal;}
> public static void Simplify_Test()
> {System.out.println("Simplify_Test:Input mathematical sentence");
> Scanner scn = new Scanner(System.in);
> String cal;
> cal = scn.nextLine();
> cal = Simplify_General(cal);
> System.out.println("Simplify_Test:Output=" + cal);}
> public static void main(String[] args)
> {Simplify_Test();}}
>
It compiles, what is it supposed to do? What input are we to give it?
--
Knute Johnson
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2014-03-25 15:12 -0700 |
| Message-ID | <6e3aae01-5526-4454-9d9a-46e6c1415cc7@googlegroups.com> |
| In reply to | #2932 |
Isaac Chan wrote:
> I have fixed most of the problems.This is supposed to change ++ into + and -- into + and +- into -.Though it compile successfully ,it refuse to function.
>
> I am new to this.Can u guys help me?
What is a "u guys"? People attached to a letter of the alphabet? I don't know if they can help you.
> import java.util.Scanner;
>
> class IngeniusXD
Why not a 'public' class?
> {Scanner scn = new Scanner(System.in);
You have been coached to follow the coding conventions. You opted to ignore the advice.
No soup for you!
> private static String Simplify(String cal ,char st ,char nd ,char rep)
> {for (int i = 0;i < cal.length() - 100; i++)
> {if ((cal.charAt(i) == st) || (cal.charAt(i + 1) == nd))
> {cal = cal.substring(0 ,i - 1) + rep + cal.substring(i + 2);}
> else if ((cal.charAt(i) == nd) || (cal.charAt(i + 1) == st))
> {cal = cal.substring(0 ,i - 1) + rep + cal.substring(i + 2);}}
> return cal;}
> public static String Simplify_General(String cal)
> {cal = Simplify(cal ,'+' ,'-' ,'-');
> cal = Simplify(cal ,'-' ,'-' ,'+');
> cal = Simplify(cal ,'+' ,'+' ,'+');
> return cal;}
> public static void Simplify_Test()
> {System.out.println("Simplify_Test:Input mathematical sentence");
> Scanner scn = new Scanner(System.in);
> String cal;
> cal = scn.nextLine();
> cal = Simplify_General(cal);
> System.out.println("Simplify_Test:Output=" + cal);}
> public static void main(String[] args)
> {Simplify_Test();}}
Your problem is that your code is unreadable garbage.
--
Lew
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.help
csiph-web