-
Re: Java Programming project
You need to copy and post the full text of error messages.
If you are having problems with mismatched {}s, some IDEs have a tool you can use to find the pairing {}s
On my IDE put the cursor just before a { and press: Ctrl and ] and the cursor will move to the pairing }.
Another way to pair {}s is to print the source on a piece of paper and use a pencil to draw lines from a { to its pairing }. Start at an inner most pair and move out.
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
-
Re: Java Programming project
Errors: ----jGRASP exec: javac -g Muffler.java
Muffler.java:72: error: reached end of file while parsing
}//end computeCost
^
Muffler.java:78: error: reached end of file while parsing
^
2 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
-
Re: Java Programming project
Again, please post your code with code tags. Please look at Norm's post to see how to do this. Again, you need to put the effort in to find matches for all of your braces. Again this isn't rocket science, since all you need to do is match 'em. Please have at it.
-
Re: Java Programming project
public void computeCost()
{}
double priceCost = 39.95;
switch(C)
{}
[case (A): cost = priceCost * 1.00;
case (A3): cost = priceCost * 41.95;
case (B): cost = priceCost * 1.07;
case (B3): cost = priceCost * 44.89;
case (BL): cost = priceCost * 48.10;
case (C): cost = priceCost * 1.15;
case (C3): cost = priceCost * 48.24;
case (CL): cost = priceCost * 51.69;
case (D): cost = priceCost * 1.22;
case (D3): cost = priceCost * 51.18;
case (DL): cost = priceCost * 54.84;
case (E): cost = priceCost * 1.38;
case (E3): cost = priceCost * 57.89;
case (EL): cost = priceCost * 62.03;
case (F3): cost = priceCost * 62.92;
case (FL): cost = priceCost * 67.42]
<return cost>
{}//[end computeCost]
Like this?
-
Re: Java Programming project
What does the compiler say?
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
-
Re: Java Programming project
-
Re: Java Programming project
Not a record, not even close.
How many errors before your last change? Restore the code to the old version and try again.
-
Re: Java Programming project
1 error: {//end computeCost
i will try again with the old version
-
Re: Java Programming project
Print the source and use a pencil to connect a { to its pairing }
Start at the inside and work out.
-
Re: Java Programming project
what source? you mean my code?
-
Re: Java Programming project
Yes, by source I meant your code before it is compiled.
-
Re: Java Programming project
-
Re: Java Programming project
-
Re: Java Programming project
and do you want me to compile it
-
Re: Java Programming project
I don't know why you would wait for someone to tell you to compile the program. Compilations are free. I compile frequently when writing a program. Its better to have fewer errors with frequent compiles rather than wait and get lots of errors.
-
Re: Java Programming project
i know ,I didn't mean to and it don't worked so i have to go back to my old version and compile successfully and move on next method 1 new errors: public String updatePriceCode(String PriceCode)
-
Re: Java Programming project
You need to copy the full text of the error messages and paste them here. We're here and you're there. We can't see what is on your PC's screen.
-
Re: Java Programming project
public class Muffler
{
private String customer;
private String priceCode;
private double cost;
public Muffler()
{
String customer = "Williams";
String priceCode = "A" ;
double cost = 39.95;
}//end Muffler
public Muffler(String inName, String inPriceCode)
{
customer = inName;
priceCode = inPriceCode;
computeCost();
}//end Muffler
public String getCustomer()
{
return customer;
}//end getCustomer
public String getPriceCode()
{
return priceCode;
}//end getPriceCode
public double getCost()
{
return cost;
}//end getCost
public String setCustomer(String newCustomer)
{
return customer;
}//end setCustomer
public void computeCost()
{
[double priceCost = 39.95]
<switch()
{
case(A): cost = priceCost * 1.00;
break;
case(A3): cost = priceCost * 41.95;
break;
case(B): cost = priceCost * 1.07;
break;
case(B3): cost = priceCost * 44.89;
break;
case(BL): cost = priceCost * 48.10;
break;
case(C): cost = priceCost * 1.15;
break;
case(C3): cost = priceCost * 48.24;
break;
case(CL): cost = priceCost * 51.69;
break;
case(D): cost = priceCost * 1.22;
break;
case(D3): cost = priceCost * 51.18;
break;
case(DL): cost = priceCost * 54.84;
break;
case(E): cost = priceCost * 1.38;
break;
case(E3): cost = priceCost * 57.89;
break;
case(EL): cost = priceCost * 62.03;
break;
case(F3): cost = priceCost * 62.92;
break;
case(FL): cost = priceCost * 67.42;
break>
[if(priceCode.length(x>1))
{
if(priceCode [1] == ("3"))
priceCost += 2.00;
else if(priceCode [1]==("L"))
priceCost+= 5.00;
else
cost=9999.99;
}
}
}//end computeCost]
public String updatePriceCode(String PriceCode)
{
return priceCode;
}//end updatePriceCode
public String toString()
{
return " ";
}//end
}//end class Muffler
Muffler.java:49: error: illegal start of expression
switch()
^
1 error
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
-
Re: Java Programming project
You've coded the switch statement many times in this thread and have always had a value inside the ()s. This time you left it out and the compiler finds it as an error.
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
-
Re: Java Programming project
-
Re: Java Programming project
Which post? What did you change?
-
Re: Java Programming project
I change from switch() to switch (c). Should I put down "c" or "cost". i hope this work this time.
-
Re: Java Programming project
-
Re: Java Programming project
i did that. the compiler won't correct my error like can't find" the symbol everything i put down word or inital in it
-
Re: Java Programming project
Quote:
the compiler won't correct my error
Not yet. They are working on it. But for now the programmer has to correct his own errors.
If you need help with the errors, copy the full text of the error messages and paste it here.