aspose file tools*
The moose likes Beginning Java and the fly likes programming help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "programming help" Watch "programming help" New topic
Author

programming help

Corey Schuh
Greenhorn

Joined: Oct 07, 2005
Posts: 3
I am creating a program that is like a change purse thing. I am having problems with the code so if anyone could help that would be great. When I compile it the error is in the 1st { after the public class Purse.

public class Purse

{
//Instance Fields
private static final double Dollars=1.00;
private static final double Quarters=0.25;
private static final double Dimes=0.10;
private static final double Nickles=0.05;
private static final double Pennies=0.01;

private double totalvalue

public Purse ()
{
totalvalue=0;
}

public void addDollars ( double amount)
{
double total=Dollars * amount;
doll=total;
}

public void addQuarters (double amount)
{
double total=Quarters * amount;
quar=total;
}

public void addDimes (double amount);
{
double total=Dimes * amount;
dim=total;
}

public void addNickles (double amount)
{
double total=Nickles * amount;
nick=total;
}

public void addPennies (double amount);
{
double total=Pennies * amount;
penn=total;
}

public double getTotalValue
{
double totalvalue=doll + quar + dim + nick + penn;
return totalvalue;
}



}
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

You might want a semicolon after the line...

private double totalvalue



"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
muhsin sabeer
Ranch Hand

Joined: Oct 01, 2005
Posts: 35
What is the error message??
Corey Schuh
Greenhorn

Joined: Oct 07, 2005
Posts: 3
ya I was missing that but it still doesnt work! Any other ideas?
Corey Schuh
Greenhorn

Joined: Oct 07, 2005
Posts: 3
Purse.java:49: ';' expected
Sudhakar Janarthanan
Greenhorn

Joined: Dec 21, 2004
Posts: 1
It looks like you haven't defined doll,quar,dim,nick and penn variables and you are trying to assign a value to it.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
As someone stated, you are missing a ; on the line that says "private double totalvalue". If you fixed this and are still getting more errors, please post the first error message from the new list along with your modified code and an indication of which line is causing the error message. We will be glad to help you figure them out one at a time.

Layne

p.s. You can use UBB CODE tags to preserve the formatting in your code.
[ October 07, 2005: Message edited by: Layne Lund ]

Java API Documentation
The Java Tutorial
S Thanigaivel
Ranch Hand

Joined: Oct 06, 2005
Posts: 60
places where u went wrong


private double totalvalue //append ;
public void addDimes (double amount); //rmv ;
public void addPennies (double amount); //rmv ;
double totalvalue=doll + quar + dim + nick + penn; //declare used vars

--------------------------------------
this works fine

public class Purse

{
//Instance Fields
private static final double Dollars=1.00;
private static final double Quarters=0.25;
private static final double Dimes=0.10;
private static final double Nickles=0.05;
private static final double Pennies=0.01;

private double totalvalue;

public Purse ()
{
totalvalue=0;
}

public double addDollars ( double amount)
{
return Dollars * amount;
}

public double addQuarters (double amount)
{
return Quarters * amount;
}

public double addDimes (double amount)
{
return Dimes * amount;
}

public double addNickles (double amount)
{
return Nickles * amount;
}

public double addPennies (double amount)
{
return Pennies * amount;
}

public double getTotalValue()
{
// pass param as per ur need...........
double totalvalue= this.addDollars(1) + this.addQuarters(1) + this.addDimes(1) + this.addNickles(1) + this.addPennies(1);
return totalvalue;
}

public static void main(String[] args)
{
System.out.println( (new Purse()).getTotalValue() );

}

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: programming help