java/programming

i did this code for this question. Write a class called PocketChange that models a handful of change you might find in your pocket. The class has the following specifications:
• Instance Variables - all instance variables are private!
- int toonies - the number of toonies in the user's pocket
- int loonies - the number of loonies in the user's pocket
- int quarters - the number of quarters in the user's pocket
- int dimes - the number of dimes in the user's pocket
- int nickels - the number of nickels in the user's pocket
- int pennies - the number of pennies in the user's pocket
• Methods:
- PocketChange() - default constructor assigns 0 as a default value to all instance variables.
- PocketChange(toonies, loonies, quarters, dimes, nickels, pennies) - sets the values of all the instance variables to the programmer-specified parameter values.
- calculateTotal method will
calculate and return the total amount of money in the user's pocket, based on the values in each of the instance variables.
- toString() - returns a String with the following format:
- Toonies: t
- Loonies: L
- Quarters: q
- Dimes: d
- Nickels: n
- Pennies: p
where t, L, q, d, n, and p are the number of toonies, loonies, quarters, dimes, nickels and pennies.
In the main method:
Write a test program to test your class.
Get user input for the pocket change he has right now. And then calculate the total value of the change. i did this code but there one line that is not working:this(toonies:0,loonies=0,quaters=0,dimes=0,nickels=0,pennies=0);

the code that i did is:
private int toonies;
private int loonies;
private int quaters;
private int dimes;
private int nickels;
private int pennies;

public PocketChange(){
// this(toonies:0,loonies=0,quaters=0,dimes=0,nickels=0,pennies=0);
}
public PocketChange(int toonies,int loonies, int quarters, int dimes, int nickels, int pennies){
this.toonies=toonies;
this.loonies=loonies;
this.quaters=quarters;
this.dimes=dimes;
this.nickels=nickels;
this.pennies=pennies;
}
public double calculateTotal(){
return toonies*2+ loonies*1 +quaters*0.25+dimes*0.10+nickels*0.05+pennies*0.01;
}
public String toString(){
return "Toonies: "+toonies+ "\nLoonies"+loonies+"\nQuaters: "+quaters+
"\ndimes:"+dimes+"\nnickels:"+nickels+"\nPennies"+pennies;
}

  1. 👍 0
  2. 👎 0
  3. 👁 194
  1. looks reasonable. Did you run it?

    1. 👍 0
    2. 👎 0
  2. yes but this line is giving me error: toonies and the semicolon this(toonies:0,loonies=0,quaters=0,dimes=0,nickels=0,pennies=0);

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. Ed Tech

    What does the code of conduct include? A. A secret code for internet users B. The conduct that should be used with a code C. A set of rules for behavior when using the internet D. A rule that tells you the code I think C Thanks!

    asked by Dancer on April 7, 2017
  2. Science

    Why do scientists use models? a: Scientists use models to learn about things that are too small, too large, or too complex to observe directly. < b:Scientists use models because doing so is always part of the scientific method.

    asked by not+really on September 28, 2017
  3. science

    Why do scientists use models? a. Scientists use models to learn about things that are too small, too large, or too complex to observe directly. b. Scientists use models because doing so is always part of the scientific method. c.

    asked by Anonymous on September 19, 2013
  4. Computer Literary

    Which of the following is Not an example of debugging A)Looking for errors in programming code B)Fixing misspelled commands in programming code C)Solving faulty logic in programming code D)Upgrading to improve the programming code

    asked by Cowanna Agee on January 17, 2015
  5. Math

    Michelle is interested in knowing how often girls in her class at school use their cell phones to instant message their friends. Which of the following methods could Michelle use to conduct a simple random sample to answer her

    asked by Sophia on October 8, 2019
  1. Physics

    Which statement reagarding the idealized model of motion called free fall is true? A. A freely falling object has a constant acceleration called the acceleration due to gravity. B. The idealized model of motion called free fall

    asked by Babygirl on September 14, 2018
  2. Business

    In a frequency distribution, what is the number of observations in a class called? A. class midpoint B. class interval C. class array D. class frequency E. none of the above

    asked by Tykrane on December 13, 2009
  3. Science

    Q1: Why do scientist use models? A.) Scientist use models to learn about things that are too small, too late, or too complex to observe directly. B.) Scientist use models because doing so is always part of the scientific method.

    asked by Help please on September 1, 2016
  4. Computer Science

    This is the problem: The following HTML code fragment contains a reference to an image file called frog.gif and with alternate text set to froggy, but the code as written contains a number of errors. Write the HTML line correctly.

    asked by Joseph on February 8, 2010
  5. Program Design and Developmen

    Design a class named TextBook that is a child class of Book. Include a new data field for the grade level of the book and get and set methods for the new field. Provide the pseudocode for the TextBook class Very basic pseudo code

    asked by alex on April 8, 2017
  6. Math

    Find the number of each kind of object in the collection Curt has 12 models in all. Three of the models are airplanes. Curt has 5 more models of cars than boats. How many models of cars does Curt have?

    asked by TJ on March 1, 2013

You can view more similar questions or ask a new question.