Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Harry Hunter   on Nov 28 In Java Category.

  
Question Answered By: Velma Adams   on Nov 28

I marked the spot where you need to put  it, it is below.

public class  ChangeMachine {


public static  boolean makeChange(int cents) {

//Shows what system  does when no change  is required
if (cents==0) {
System.out.println(" No Change Is Due") ;
return true;
}
//Change will only be given for positive numbers  less than 99.
if ((cents <= 99) && (cents > 0)) {
System.out.println ("Dispensing " + cents + " cents:") ;
return true;
}


}******** Bracket here *******


/*the below line  is the one with the problems, illegal start  of the
expression*/
public static void  main(String args[]){
//Creating the ints of all of the coins
int quarters;
int dimes;
int nickles;
int pennies;
String ans;
final int  RANGE=4;

//The number  given by each of the coins is calculated
quarters = (cents / 25);
dimes = ((cents % 25) / 10);
nickles = (((cents % 25) % 10) / 5);
pennies = ((((cents % 25) % 10) % 5) / 1);


//It will print  out the numbers given by each coin
if ((quarters) > (0)) {
System.out.println(" Quarters: " + quarters);
}

if ((dimes) > (0)) {
System.out.println(" Dimes: " + dimes);
}

if ((nickles) > (0)) {
System.out.println(" Nickles: " + nickles);
}

if ((pennies) > (0)) {
System.out.println(" Pennies: " + pennies);
}

//If number is not in the range  given above, it will print out the
below statement.
else {
System.out.println( "Invalid Change Amount (" + cents + "
cents)");
return false;
}

};
/*i don't know why, but for some reason it asked  me to put a
semi-colon after the bracket above  */ }

}

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on change machine programming Or get search suggestion and latest updates.


Tagged: