I am studying Programming and trying to get my assignment to work
the problem is with the MAINTENANCE PART in red I can get it to work!
Can anyone help!!!!
-----------------------------------------------------------------------
public class Assignment2 {
static final int TotalCans = 50; // The total number of cans avaliable
static String Drinks[] ={"Coke", "Sprite", "Water", "Orangina"};
static String Price[] ={"40p", "50p", "80p", "70p"};
static String Coins[] ={"10", "10", "10", "10"};
static String Accept[] ={"5p", "10p", "20p", "50p"};
public static void main(String arg[])
{
/*-- initial setting--------------------------*/
int Cans[] = new int[4];
for (int i=0; i<4; i++)
Cans[i]=(int)(TotalCans*Math.random());
//Then goes the major part of selecting and executing either BUY or Mainenance, each presented with a specific method.
/*-- users action menue to choose from----- */
int MenueItem=1;
while (MenueItem!=0){
MenueItem=menue();// a method GO TO QUIT
if (MenueItem==1)
MAINTENANCE(Cans); // a method GO TO MAINTENANCE
else if (MenueItem==2)
Cans=BUY(Cans); // a method BUY A DRINK
}//end of while for choosing action
} //end of main
/*--------- three methods,
menue,
Mainenance,
BUY
to specify----------------------------------*/
/*--BUY A DRINK to select performance and number of Cans: transform array of booked Cans --- */
public static int[] BUY(int[] per){
for (int i=0;i diff)
TextIO.putln("We have only " + diff + " Cans remaining in the machine");
else { // per[choice] = per[choice] + NoOfCans;
per[choice]+=NoOfCans;
TextIO.putln("You have purchased " + NoOfCans + " Cans of ");
}
} // end of else.
return per;
}// end of method BUY
/*--BUY to select performance and number of Cans: transform array of booked Cans --- */
//------------------------------------------------------------------------------------------------------------------*/
/*--- ONE/MAINTENANCE for outputting statistics--- */
public static int[] MAINTENANCE(int[] machine){
TextIO.putln("Want to perform Maintenance checks? ");
TextIO.putln("1 - The amount of cans of each type of drink available currently"); //ISSUE 1
TextIO.putln("2 - The total amount of cans in the machine = "); //ISSUE 2
TextIO.putln("3 - The amount of coins of each denomination there is in this machine currently"); // ISSUE 3
TextIO.putln("4 - The amount of money in total there is in the machine currently ");// ISSUE 4
TextIO.putln();
TextIO.putln("Select 1,2,3,4 to pick which MAINTENANCE check ");
int choice2;
choice2 = TextIO.getInt()-1;
}
}
return machine;
}
class MAINTENANCE2(int [] arr){
switch (int choice2) {
case 1 : {
int ii=0; ii