Given below is the code for the question.
To indent code in eclipse , select code by pressing ctrl+a and then
indent using ctrl+i
Please do rate the answer if it was helpful. Thank you
Coins.java
-=-----
public class Coins {
private int numQuarters;
private int numDimes;
private int numNickels;
private int numPennies;
public Coins()
{
}
public Coins(int quarters, int dimes, int nickels, int
pennies)
{
numQuarters = quarters;
numDimes = dimes;
numNickels = nickels;
numPennies = pennies;
}
public int getNumQuarters() {
return numQuarters;
}
public void setNumQuarters(int numQuarters) {
this.numQuarters = numQuarters;
}
public int getNumDimes() {
return numDimes;
}
public void setNumDimes(int numDimes) {
this.numDimes = numDimes;
}
public int getNumNickels() {
return numNickels;
}
public void setNumNickels(int numNickels) {
this.numNickels = numNickels;
}
public int getNumPennies() {
return numPennies;
}
public void setNumPennies(int numPennies) {
this.numPennies = numPennies;
}
public double totalAmount()
{
double total = numQuarters * 25 + numDimes * 10 + numNickels * 5 +
numPennies; //total no. of pennies
return total/100; //dollar cents
}
public String toString()
{
return String.format("Total Value:$%.2f \t %d quarters, %d dimes,
%d nickels, %d pennies",
totalAmount(), numQuarters, numDimes, numNickels,
numPennies);
}
}
CoinsTester.java
--------
public class CoinsTester {
public static void main(String[] args) {
Coins c = new Coins(10, 20, 19, 5);
System.out.println(c.toString());
}
}
output
=======
Total Value:$5.50 10 quarters, 20 dimes, 19 nickels, 5 pennies
Write a class encapsulation the concept of coins (Coins java), assuming that coins have the following...
Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters, number of dimes, number of nickels, and number of pennies. Include two constructors (non-argument constructor that assigns 1 to each coin, and another constructor that takes necessary arguments to create an object), needed getter and setter methods, method toString (to print coins objects in a meaningful way), and method equals (to compare two coins objects based on number of coins). Also include...
it c++ coding. please write on atom software.
1. Write a program that converts dollars into coins a. Request a dollar amount as an integer: $5.34 is input as 534 b. Use a constant variable to represent each coin as a fixed value: const int NICKEL 5; c. Use division and the mod function to calculate the number of each coin. Change Calculator Enter dollar amount (as an integer): $534 The equivalent in coins: 21 Quarters 0 Dimes 1 Nickels...
implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...
Write a class encapsulating the concept of a vendor, if a vendor has the following attributes: company name, id, array of quarterly purchase order totals (4 double elements). Include a constructor, accessor, mutator, and toString methods. Also code the following methods: one returning the total purchase orders (total all array elements) and a method to modify an array element (change the value of an array element). Write a client class to create 2 vendor objects and test all your methods.
STORAGE WARS - Create a class with the name and variables/attributes listed below. Create a default Constructor with no parameters that assigns default values for each variable. Then, create an overloaded Constructor (with one parameter for each variable). Finally, create a method that returns the total number of items in the storage container. NOTE: this method must not print anything. (50 points) Make sure to clearly label the variables/attributes, Constructors and Methods and to indicate which language you are answering...
implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...
Using Java Write a class encapsulating the concept of student grades (50 elements) on a test, assuming student grades are composed of a list of integers between 0 and 100. Write the following methods: A constructor with just one parameter, the number of students; all grades can be randomly generated Accessor, mutator, toString, and equals methods A method returning the highest grade A method returning the average grade A method returning the lowest grade Write a client class to test...
write a class encapsulating the concept of a student assuming
that the student has the following attributes the name of student
the average of the student the
rite a class encapsulating the concept of a Student, assuming that the Student has the following attributes: the name of the student, the average of the student, and the student's GPA. Include a default constructor, an overloaded constructor, the accessors and mutators, and methods, toString() and equals(). Also include a method returning the...
using java write a code with notepad++ Create the following classes using inheritance and polymorphism Ship (all attributes private) String attribute for the name of ship float attribute for the maximum speed the of ship int attribute for the year the ship was built Add the following behaviors constructor(default and parameterized) , finalizer, and appropriate accessor and mutator methods Override the toString() method to output in the following format if the attributes were name="Sailboat Sally", speed=35.0f and year built of...
Write a program called CountCoins.java that prompts the user for the input file name (you can copy the getInputScanner() method given in the ProcessFile assignment) then reads the file. The file contains a series of pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be “pennies” (1 cent each), “nickels” (5 cents each), “dimes” (10 cents each), or “quarters” (25 cents each), case-insensitively. Add up the cash values of...