I have this project that I have been working on, but I'm a bit rusty so I could use some help to figure out this part.
The main jizt of my project, is that I want to be able to fire a gun at a target and have the target analyze my data.
Before I even start on this, I did some research to find out if anyone else had done this before, and turns out a company in USA have done it, but in a different way than what I imagined..
This is not meant as a business idea, just a fun project for my self :)
Now here is my issue, I ofcourse made a "prototype" without the gun, and without the targets.
All text in Java to see if I could make this work.
I researched a bit since I was rusty (and still am), and figured out most of the problems I faced.
The part that has me stuck is at the very end of it, I have an array for all the shots but I want to divide this array into multiple arrays with the size of the magazine capacity.
How would I accomplish this?
Unfortunately I don't save my code, if I chose to delete it, so my scraps are long gone, but I have tried a few things that came to mind and for several days I havn't been able to figure this one out..
I tried with nested for loops, then I tried again but with nested for loops in a while loop, and I probably tried a few different things aswell.
if (hasrun == true) {
//OUTPUT
ms(2);
System.out.print("You shot the following:");
nl(1);
int counter = 0;
int i = 0;
while (sf > magcap) {
sf-=magcap;
mnm++;
}
while (counter <= mnm) {
System.out.print("Mag " + mn + ": ");
for (i+=0; i < magcap; i++) {
System.out.print(shots[i] + " ");
}
counter++;
mn++;
nl(1);
}
Just to clarify some things in my code here, I know this isn't the cleanest code, I'm not going for clean, and I know I don't need half of my functions (methods), but I did them to practice so they're there. Any help would be greatly appreciated with solving my problem tho! :)
If you want to have a look at all of my code for this project, head over to pastebin
You can use Guava to do it easily,
int[] x = {1,2,3,4,5,6};
int splitSize = 3;
List<Integer> list = IntStream.of(x).boxed().collect(Collectors.toList());
//partition
List<List<Integer>> partitioned = Lists.partition(list, splitSize);
//result: [[1,2,3], [4,5,6]]
Using System.arraycopy:
import java.util.Arrays;
public class Testing {
// static int[] input = {1,2,3,4,5,6}; // testdata
static int[] input = {1,2,3,4,5,6,7}; // testdata
// static int[] input = {1,2,3,4,5,6,7,8}; // testdata
static int magSize = 3; // testdata
// static int magSize = 5; // testdata
public static void main(String[] args) {
// int resultSize = (int) Math.ceil((double) input.length / magSize);
int resultSize = input.length % magSize == 0 ?
input.length/magSize :
input.length/magSize + 1;
int[][] result = new int[resultSize][magSize];
for (int i = 0; i < resultSize; i++) {
System.arraycopy(input, // src
i*magSize, // srcPos
result[i], // dest
0, // destPos
(i + 1) * magSize < input.length ?
magSize :
input.length - i*magSize); // length
}
System.out.println("Original : " + Arrays.toString(input));
System.out.println("Result : " + Arrays.deepToString(result));
/*
prints:
Original : [1, 2, 3, 4, 5, 6, 7]
Result : [[1, 2, 3], [4, 5, 6], [7, 0, 0]]
*/
}
}
I figured it somewhat out, here is what I did. Not quite implemented yet, but this worked with an array.
// OUTPUT
while (sf >= magcap) {
sf -= magcap;
mn++;
}
ms(2);
System.out.println(mn + " mags and " + sf + " shots fired");
nl(2);
for (int i = 0; i < mn; i++) {
from = magcap * magcounter - magcap;
to = magcap * magcounter;
System.out.print("Mag " + magcounter + ": ");
for (int j = from; j < to - 1; j++) {
System.out.print(shots[j] + ", ");
}
System.out.print(shots[to - 1] + ".");
magcounter++;
nl(1);
}
// PRINT THE REST
if (sf >= 1) {
from = magcap * magcounter - magcap;
to = magcap * magcounter;
if (sf == 1) {
System.out.print("Mag " + magcounter + ": ");
System.out.print(shots[from] + ".");
} else {
System.out.print("Mag " + magcounter + ": ");
for (int i = 0; i < sf - 1; i++) {
System.out.print(shots[from + i] + ", ");
}
from += sf -1;
System.out.print(shots[from] + ".");
}
}
The output is
1 2 3 4 5 6 7 8 9 10
3 mags fired and 1 shots fired
Mag 1: 1 2 3
Mag 2: 4 5 6
Mag 3: 7 8 9
Mag 4: 10
Related
I'm having trouble with Usaco training gate's milking time problem (aka milk2). My code works for the first few problems, but then doesn't work for one of the cases.
The problem is here:http://jeremiahflaga.blogspot.com/2011/09/milking-cows-programming-problem-from.html
The case that doesn't work is: [1, 2] [3, 4] [5, 6] [7, 8] [9, 10] [11, 12] [13, 14] [15, 16] [17, 18] [19, 20] [1, 20]
I think it is because of the last [1, 20], and it makes my code not work as I don't think I'm managing the merging correctly, but I've tried for some time and ended up making the code worse.
import java.io.*;import java.util.*;
public class milk2 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("milk2in.txt"));
PrintWriter pw = new PrintWriter(new File("milk2.out"));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
String line = "";
int milkInterval = 0;
int largestMilkInterval = 0;
int noMilkInterval = 0;
int largestNoMilkInterval = 0;
milkingTime[] times = new milkingTime[N];
for (int i = 0; i < times.length; i++) {
st = new StringTokenizer(br.readLine());
milkingTime mt = new milkingTime(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
times[i] = mt;
}
System.out.println(Arrays.toString(times));
for (int i = 0; i < times.length - 1; i++) {
noMilkInterval = 0;
if (times[i].getEnd() >= times[i + 1].getStart()) {
if (times[i].getStart() > times[i + 1].getStart()) {
milkInterval += times[i + 1].getEnd() - times[i + 1].getStart();
} else {
milkInterval += (times[i].getEnd() - times[i].getStart()) + (times[i + 1].getEnd() - times[i + 1].getStart());
}
System.out.println("Milk Interval: " + milkInterval);
} else {
milkInterval += (times[i].getEnd() - times[i].getStart());
if (milkInterval > largestMilkInterval) {
largestMilkInterval = milkInterval;
}
milkInterval = 0;
noMilkInterval += times[i + 1].getStart() - times[i].getEnd();
System.out.println("No milk interval: " + noMilkInterval);
}
if (noMilkInterval > largestNoMilkInterval) {
largestNoMilkInterval = noMilkInterval;
}
if (milkInterval > largestMilkInterval) {
largestMilkInterval = milkInterval;
}
}
if (times.length == 1) {
largestMilkInterval = times[0].getEnd() - times[0].getStart();
largestNoMilkInterval = 0;
}
System.out.println("Largest Milk Interval: " + largestMilkInterval);
System.out.println("Largest no milk Interval: " + largestNoMilkInterval);
// pw.println(largestMilkInterval + " " + largestNoMilkInterval);
// pw.close();
}
}
class milkingTime {
private int start;
private int end;
public milkingTime(int s, int e) {
start = s;
end = e;
}
public int getStart() {
return start;
}
public int getEnd() {
return end;
}
public String toString() {
return "Start: " + start + " End: " + end;
}
}
I also wonder if my code is just completely wrong, and this is not the correct direction of solving this problem.
Your solution seems wrong.
The main mistake is an assumption you apparently made, that you can find all important correlations between given intervals in a single pass along the table. Alas, the problem formulation makes no guarantee the intervals are given in any specific order. It even specifically mentions there are several 'farmers' milking – so their repective schedules may make a total input unordered when concatenated, even if each schedule is ordered. This is a case in your example data, which contains an ordered run of ten intervals
[1, 2] [3, 4] ... [19, 20]
and then another single-interval run
[1. 20]
which covers the former.
To handle that, I'd recommend sorting the data by a start time of intervals:
[1, 2] [1, 20] [3, 4] ... [19, 20]
Every two intervals with the same start time overlap, and now they sit in a contiguous block of the array, so we can easily find them. Additionally, an i-th interval overlaps some further k-th interval (with i less than k) if, and only if, the i-th one ends at the same time or later than the k-th one starts.
This is how I would merge them:
int curr = 0; // the interval to receive a merge
int next = 1; // the interval to be possibly merged into current
while (next < N)
{
if (times[curr].getEnd() >= times[next].getStart()) // overlapping?
{
times[curr].expandTo( times[next].getEnd() ); // merge to the current
}
else
{
++ curr; // finished merging to current
if (curr != next) // some items got merged
times[curr] = times[next]; // shift further items to emptied space
}
++ next;
}
newN = curr + 1; // number of separate intervals after all merges
Thanks to prior sorting we know the k-th interval can't start before the i-th one if i<k so the single condition reliably indicates all overlaps.
Of course the expandTo method in the milkingTime class must increase the end time to cover the given value:
class milkingTime {
.....
public void expandTo(int targetTime)
{
if (getEnd() < targetTime) {
setEnd(targetTime);
}
}
}
Now finding the longest interval and the longest gap is straight forward:
int longestInterval = 0;
for (int i = 0; i < newN; ++ i) {
if (times[i].getLength() > longestInterval)
longestInterval = times[i].getLength();
}
int longestGap = 0;
for (int i = 1; i < newN; ++ i) {
int gap = times[i].getStart() - times[i - 1].getEnd();
if (gap > longestGap)
longestGap = gap;
}
How to find repeating sequence of Integers in an array of Integers?
00 would be repeating, so would 123123, but 01234593623 would not be.
I have an idea to how to do this, but it is blurry in my mind, and my implementation doesn't go far due to this.
My idea was
Offset by a certain amount each time going through a for loop
Loop through inside of that and compare chunks of numbers by that offset
In Java, I got this far:
String[] p1 = new String[nDigitGroup];
String[] p2 = new String[nDigitGroup];
for (int pos = 0; pos < number.length - 1; pos++)
{
System.out.println("HERE: " + pos + (nDigitGroup - 1));
int arrayCounter = -1;
for (int n = pos; n < pos + nDigitGroup ; n++)
{
System.out.printf("\nPOS: %d\nN: %d\n", pos, n);
arrayCounter++;
p1[arrayCounter] = number[n];
System.out.println(p1[arrayCounter]);
}
pos += nDigitGroup;
arrayCounter = -1;
System.out.println("SWITCHING");
for (int n = pos; n < pos + nDigitGroup ; n++)
{
System.out.printf("\nPOS: %d\nN: %d\n", pos, n);
arrayCounter++;
p2[arrayCounter] = number[n];
System.out.println(p2[arrayCounter]);
}
if (p1[0].equals(p2[0]) && p1[1].equals(p2[1])) System.out.println("MATCHING");
}
When ran with these arguments:
repeatingSeqOf(2, new String[] {"1", "2", "3", "4", "5", "6", "7", "7" });
I am correctly filling the section arrays, but it breaks on an index out of bounds exception.
#MiljenMikic answer's is great, especially since the grammar isn't actually regular. :D
If you want to do it on an array in general, or want to understand it, this does pretty much exactly what the regex does:
public static void main(String[] args) {
int[] arr = {0, 1, 2, 3, 2, 3}; // 2, 3 repeats at position 2.
// for every position in the array:
for (int startPos = 0; startPos < arr.length; startPos++) {
// check if there is a repeating sequence here:
// check every sequence length which is lower or equal to half the
// remaining array length: (this is important, otherwise we'll go out of bounds)
for (int sequenceLength = 1; sequenceLength <= (arr.length - startPos) / 2; sequenceLength++) {
// check if the sequences of length sequenceLength which start
// at startPos and (startPos + sequenceLength (the one
// immediately following it)) are equal:
boolean sequencesAreEqual = true;
for (int i = 0; i < sequenceLength; i++) {
if (arr[startPos + i] != arr[startPos + sequenceLength + i]) {
sequencesAreEqual = false;
break;
}
}
if (sequencesAreEqual) {
System.out.println("Found repeating sequence at pos " + startPos);
}
}
}
}
You can always play with regular expressions to achieve a desired result. Use the regex backreference and combine it with the greedy quantifier:
void printRepeating(String arrayOfInt)
{
String regex = "(\\d+)\\1";
Pattern patt = Pattern.compile(regex);
Matcher matcher = patt.matcher(arrayOfInt);
while (matcher.find())
{
System.out.println("Repeated substring: " + matcher.group(1));
}
}
The answer posted by #AdrianLeonhard is perfectly working. But if I have a sequence of
0, 1, 2, 3, 4, 3, 5, 6, 4, 7, 8, 7, 8
many might be wondering on how to get all the repeated numbers from the array.
So, I wrote this simple logic which prints all the repeated numbers with their positions
int[] arr = {0, 1, 2, 3, 4, 3, 5, 6, 4, 7, 8, 7, 8};
for(int i=0; i<arr.length;i++){
for(int j=i+1; j<arr.length;j++){
if(arr[i] == arr[j]){
System.out.println("Number: "+arr[i]+" found repeating at position: "+i+" , repeated at position "+j);
}
}
}
Try this:
string lookIn = "99123998877665544123";
// above has length of 20 (in positions 0 through 19)
int patternLength = 3;
// want to search each triple of letters 0-2, 1-3, 2-4 ... 17-19
// however since there must be 3 chars after the 3-char pattern
// we only want to search the triples up to 14-16 (20 - 3*2)
for (int i=0; i <= lookIn.Length - patternLength * 2; i++) {
string lookingFor = lookIn.Substring(i, patternLength);
// start looking at the pos after the pattern
int iFoundPos = lookIn.IndexOf(lookingFor, i + patternLength);
if (iFoundPos > -1) {
string msg = "Found pattern '" + lookingFor
+ "' at position " + i
+ " recurs at position " + iFoundPos;
}
}
// of course, you will want to validate that patternLength is less than
// or equal to half the length of lookIn.Length, etc.
EDIT: improved and converted to javascript (from C# ... oops, sorry about that...)
function testfn() {
var lookIn = "99123998877665544123";
// above has length of 20 (in positions 0 through 19)
var patternLength_Min = 2;
var patternLength_Max = 5;
if (patternLength_Max > (lookIn.length / 2)
|| patternLength_Max < patternLength_Min
|| patternLength_Min < 1) {
alert('Invalid lengths.')
}
var msg = "";
for (var pLen = patternLength_Min; pLen <= patternLength_Max; pLen++) {
for (var i = 0; i <= lookIn.length - pLen * 2; i++) {
var lookingFor = lookIn.substring(i, i + pLen);
// start looking at the pos after the pattern
var iFoundPos = lookIn.indexOf(lookingFor, i + pLen);
if (iFoundPos > -1) {
msg = msg + "Found '" + lookingFor
+ "' at pos=" + i
+ " recurs at pos=" + iFoundPos + "\n";
;
}
}
}
alert(msg);
}
The message box displays the following:
Found '99' at pos=0 recurs at pos=5
Found '12' at pos=2 recurs at pos=17
Found '23' at pos=3 recurs at pos=18
Found '123' at pos=2 recurs at pos=17
I want to move cursor up to the beginning after it wrote something at lower part. I mean is there something like SetCursorPosition(0,0)?
edit: it is about writing 6x3 matrix with numbers in it. it should be seem like this
...
7 8 9
4 5 6
1 2 3
it'll start write from bottom. when the cursor at (0,0) it'll put 6x space then write 1 2 3, then go to (0,0), put 5x space, write 4 5 6 ...
code:
boolean sa;
int yoyo;
int lo = 18;
int y = 0;
for (int k = 1; k < 100; k++)
{
if (y < 18)
{
sa = true;
for (int h = 2; h < k; h++)
{
if (k % h == 0)
sa = false;
}
if (sa)
{
lo--;
if (y % 3 == 0)
{
yoyo = lo / 3 + 1;
// here where I need Console.SetCursorPosition(0,0)
for (int yos = 0; yos < yoyo; yos++)
{
System.out.print("\n");
}
if (k < 10)
System.out.print(" " + k + " ");
else
System.out.print(k + " ");
}
else
{
if (k< 10)
System.out.print(" " + k + " ");
else
System.out.print(k + " ");
}
y++;
}
}
}
Unfortunately, Java doesn't have full console support.
You might try JLine.
I asked the developers of JLine and you can set the cursor position using this.
terminal.puts(InfoCmp.Capability.cursor_address, 0, 0);
Here's a small example of it's usage and as an added bonus I'll show how to make the cursor invisible and visible.
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import org.jline.utils.InfoCmp;
import java.io.IOException;
public class CursorStuff
{
public static void main(String[] args) throws IOException, InterruptedException
{
int row = 10;
int col = 40;
Terminal terminal = TerminalBuilder.terminal();
terminal.puts(InfoCmp.Capability.cursor_address, row, col);
System.out.println("Here we start at row " + row + " col " + col);
System.out.println("Now you see the cursor");
Thread.sleep(2000);
terminal.puts(InfoCmp.Capability.cursor_invisible);
System.out.println("Now you don't!");
Thread.sleep(2000);
terminal.puts(InfoCmp.Capability.cursor_visible);
System.out.println("And the cursor is back again.");
}
}
Make sure to have either Jansi or JNA in your libraries otherwise you will get a dumb terminal and not be able to use these functions at least on Windows as it requires these to do native function calls.
As far as I can tell this is the easiest method to accomplish this as before I knew this was an option I was writing C++ and calling those native function calls I made using JNI.
I'm sure I'm making a rookie mistake with java(this is actually my first program). I am trying to port some working python code I made into java(as a learning/testing exercise to learn a bit of the differences) but I'm getting different results between the two.
My program takes a list of data and generates another list based on it(basically sees if a value can be broken down by a sum). Python correctly gives 2,578 results while Java only gives 12. I tried to find the same commands in java and thought I did but can't seem to figure out why the results differ(the difference between the two I have experienced problems with multi threading and syncing of variables, wasn't sure if Java was doing anything behind the scenes so I had a while loop to keep running until the results stabilize, but it didn't help). Any suggestions would be helpful.
Here's the offending code(java at the top, python and pseudo code commented out in the bottom as reference):
for (int c = 0; c <= max_value; c++){
String temp_result = (s - c * data.get(i) + "," + i);
if( results.contains( temp_result ) ){
String result_to_add = (s + "," + i+1);
if( results.contains( result_to_add ) ){
System.out.println("contains result already");
} else {
results.add(result_to_add);
} print len(T)
#Here's the basic pseudo code(I added a few control variables but here's a high level view):
for i = 1 to k
for z = 0 to sum:
for c = 1 to z / x_i:
if T[z - c * x_i][i - 1] is true:
set T[z][i] to true
*/
In java s + "," + i+1 is a String concatenation : "10" + "," + 4 + 1 will return 10,41.
Use String result_to_add = s + "," + (i+1); instead.
I see you've solved it just now, but since I've written it already, here's my version:
This uses the trick of using a Point as a substitute for a 2-element Python list/tuple of int, which (coincidentally) bypasses your String concatenation issue.
public class Sums
{
public static void main(String[] args)
{
List T = new ArrayList();
T.add(new Point(0, 0));
int target_sum = 100;
int[] data = new int[] { 10, -2, 5, 50, 20, 25, 40 };
float max_percent = 1;
int R = (int) (target_sum * max_percent * data.length);
for (int i = 0; i < data.length; i++)
{
for (int s = -R; s < R + 1; s++)
{
int max_value = (int) Math.abs((target_sum * max_percent)
/ data[i]);
for (int c = 0; c < max_value + 1; c++)
{
if (T.contains(new Point(s - c * data[i], i)))
{
Point p = new Point(s, i + 1);
if (!T.contains(p))
{
T.add(p);
}
}
}
}
}
System.out.println(T.size());
}
}
As a graduate I went for an interview for a java development role and was doing pretty well in the technical examinations until i came up against this question.
If i was setting up a vending machine which (for simplicity) returned £2 change. How would i produce an implemtation that would list all the possible combinations of £2.
For e.g £1 + £1 , £1 + 50p + 50p, 50p + 50p + 50p + 50p and so on..
How could i list all the different combinations of £2.00 change possible by the vending machine.
I began to write something and this is what ive came up with so far.
Its almost working except can someone help me find out why its not expanding fully. A second pair of eyes will be grateful. And also any ways it can be optimised.
Thanks guys.
private static void printCoins(int[] tempArray) {
for (int i = 0; i < tempArray.length - 1; i++){
// to stop my array from printing out any non-denominator coins e.g
if (tempArray[i] > 0){
System.out.print(tempArray[i] + ": ");
}
System.out.println("\n");
}
}
public static void vendingMachine() {
int[] denominations = {200,100, 50, 20, 10, 5, 2, 1};
int[] tempArray = new int[50]; //combination of coins made
int total = 200;
int coinCombiIndex = 0, denomCoinIndex = 0;
// whilst all denominations havent been visited
while (denomCoinIndex < denominations.length)
// if i have the correct change
if (total - denominations[denomCoinIndex] == 0){
tempArray[coinCombiIndex] = denominations[denomCoinIndex];
denomCoinIndex++; //increment so that next iteration starts with lower denom
printCoins(tempArray); // return coins
}
// checks to see whether new total minus coin (denominator) is still >= 0
else if (total - denominations[denomCoinIndex] >= 0) {
// if so SUBTRACT from total and ADD coin to coin-combination-array
total = total - denominations[denomCoinIndex];
tempArray[coinCombiIndex] = denominations[denomCoinIndex];
coinCombiIndex++;
}
else {
denomCoinIndex++;
}
// printCoins(tempArray);
}
my output
200:
100: 100:
100: 50: 50:
100: 50: 20: 20: 10:
100: 50: 20: 20: 5: 5:
100: 50: 20: 20: 5: 2: 2: 1:
To answer your second question:
Try with only {20,10} you will see that your program is really not right .
You tried to transform my recurence into a loop, and I guess it's the best solution. But it's very difficult to do that in one loop (you're missing a lot of possibilities).
You can try to reinialise the while loop with different constraint at each step for example adding a new while loop around your loop like this one
while (i<denominations.length){
total=200;
denomCoinIndex=i;
tempArray = new int[1000];
i++;
but it's still not enough ... so you will need to add some loop again until you treat all the cases.
I don't think your approach with a while loop is the good one here.
The easiest way would be to use for loop like this to treat all the possible solutions (from the similar question to your question):
int total = 200;
System.out. printf("quarter\tdime\tnickle\tpenny\tto make %d\n", total);
int combos = 0;
for (int q = 0; q <= total / 25; q++)
{
int total_less_q = total - q * 25;
for (int d = 0; d <= total_less_q / 10; d++)
{
int total_less_q_d = total_less_q - d * 10;
for (int n = 0; n <= total_less_q_d / 5; n++)
{
int p = total_less_q_d - n * 5;
System.out.printf("%d\t%d\t%d\t%d\n", q, d, n, p);
combos++;
}
}
}
System.out.printf("%d combinations\n", combos);
Hope it helps
Probably get started on looking at Dynamic programming. However you could any approach problem for that matter trivially. How would you do that manually ??. Jot down the steps. Convert it into an algorithm yourself. Probably studying Permutations & Combinations would help for better understanding of the problem you have stated.
Hope it helps.
Let say your possible coins are x1 ...xn :
if you're asked to print all the possiblities for $2 then you could print recursively all the possibilities for :
2-x1
2-x2
..
2-xn
Yoou will eventually get all the solutions
You can initialise this recursive process with amount-xi = 0 then print
Reframe the problem as follows: Given a standard (modern) car odometer that registers 6 digits with no fractions, find all possible values where the sum of the digits is some value, say 15. If you can solve that, you can solve the given problem.
Algorithm F on (in-text) page 7 is exactly what you're looking for. :)
http://www-cs-staff.stanford.edu/~uno/fasc3a.ps.gz
public class VendeningMachine
{
public static final int[] coins = {1, 5, 10, 25};
public static final int[] coinMax = {200, 40, 20, 8};
public static final int[] coinsString = { "Penny", "Nickle", "Dime", "Quarter"};
public static void main(String[] args)
{
}
public static void vendingMachine()
{
for ( int a = 0; a <= coinMax[0]; a++ ) {
for ( int b = 0; b <= coinMax[1]; b++ ) {
for ( int c = 0; c < coinMax[2]; c++ ) {
for ( int d = 0; d < coinMax[3]; d++ ) {
checkCoins(a, b, c, d);
}
}
}
}
}
public static void checkCoins(int penny, int nickle, int dime, int quarter)
{
int total = coins[0] * penny + coins[1] * nickle + coins[2] * dime + coins[3] * quarter;
if ( total == 200 )
printCoins(penny, nickle, dime, quarter);
}
public static void printCoins(int penny, int nickle, int dime, int quarter)
{
System.out.println("Penney : " + penny + " Nickle: " + nickle + " Dime: " + dime + " Quarter: " + quarter);
}
}enter code here