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=(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----- */
MAINTENANCE(Cans);   // a method GO TO MAINTENANCE

}//end of while for choosing action
} //end of main

/*--------- three methods,
Mainenance,
to specify----------------------------------*/
/*--BUY A DRINK to select performance and number of Cans: transform array of booked Cans --- */

for (int i=0;i<per.length;i++)
TextIO.putln((i+1) + "- A can of "+ Drinks + " costs " + Price + " ");
TextIO.putln();
TextIO.putln("Select 1,2,3,4 to select a drink ");
int choice;
choice = TextIO.getInt()-1;
TextIO.putln();
if (per[choice] == TotalCans) {
TextIO.putln("This "+ (choice+1) + " is sold out");
}
else {
TextIO.putln("This machine only accepts 5p, 10p, 20p and 50p coins. Please insert your coins");
int NoOfCans = TextIO.getInt();
int diff=TotalCans-per[choice];
if (NoOfCans >  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;

/*--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<arr.length; ii++)
TextIO.putln("There are  " + arr[ii] + " cans of "  + Drinks[ii]+" left");
break; //1 - The amount of cans of each type of drink available currently
}
case 2 : {
TextIO.putln("The total amount of cans in the machine =  ?  ");
break; //2 - The total amount of cans in the machine
}
case 3 : {
int ii=0; ii<arr.length; ii++)
TextIO.putln("There are  " + arr[ii] + " coins of "  + Drinks[ii]+" left");
break; //3 - The amount of coins of each denomination there is in this machine currently
}
case 4 : {
TextIO.putln("There is ? in total in this machine  ");
break; //4 - The amount of money in total there is in the machine currently
}
}
}
getMaintenance2(){
return MAINTENANCE2;
//------------------------------------------------------------------------------------------------------------------*/

/*--- MENUE for choosing action----------- */
TextIO.putln();
TextIO.putln(" 0 - to quit ");
TextIO.putln(" 1 - to get a Mainenance ");
TextIO.putln(" 2 - to BUY a drink ");
int item=TextIO.getInt();
return item; }
}// End of class Assignment2
``````

Edited by pyTony: fixed formating

2
Contributors
1