java/programming

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.

  1. 👍 0
  2. 👎 0
  3. 👁 184
  1. I assume you know how to read two values: #coins, value
    so, loop till input is all retrieved.
    The total value of the change adds up #coins * value for each coin
    That should get you started

    1. 👍 0
    2. 👎 0
  2. ok thanks

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. Algebra2

    suppose c and d vary inversely and d=2 when c=17 write an equation that models that variation find d when c=68

    asked by Steve on February 19, 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. math

    Write and solve the differential equation that models the verbal statement. The rate of change of N is proportional to N. (Use k for the proportionality constant.) dN dt = N(t) = I mainly need help with the bottom part below this

    asked by Anonymous on March 6, 2019
  5. english

    write a letter to your friend in another school telling him/her at least three ways you find life in the final year class is different from being in the class

    asked by Max okofo darteh on February 11, 2015
  1. math

    The sum of two consecutive integers is –49. Write an equation that models this situation and find the values of the two integers.

    asked by brittany on March 19, 2015
  2. 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
  3. math

    Suppose c and d vary inversely, and d = 2 when c = 17. a. write an equation that models the variation? b. find d when c = 68

    asked by johnn on February 21, 2019
  4. math

    a man has 35 models. he has 4 times as many airplane models as he does helicopter models. how many airplane models does he have?

    asked by Anonymous on September 30, 2014
  5. Algebra 1

    1). Last week, the ratio of laptops to desktops sold at a computer store was 2:3. Eighteen desktop models were sold. How many laptop models were sold? A: 12 laptop models were sold. 2). Find the unite rate: twenty-six crackers

    asked by Anonymous on October 2, 2013
  6. 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

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