This program should have a menu:it can use a switch method ...
MENU:
[1]=ACCEPT;
[2]=DISPLAY THE SMALLEST;
[3]=DISPLAY THE LARGEST;
[4]=DISPLAY THE SUM;
[5]=DISPLAY ALL;
[6]=EXIT;
Could someone help me to this problem,and this program that i do i still encountering some errors..please do try to help me..
import java.util.*;
public class List3{
private final int [] arr;
private final int MAX=10;
public List3(){
arr=new int[MAX];
}//ACCEPT 10 NUMBERS
public void accept(){
Scanner console=new Scanner(System.in);
for(int i=0;i<arr.length;i++)
arr[i]=console.nextInt();
}
public int smallest(){
int smallest=0;
for(int i=0;i<arr.length;i++)
smallest=Math.min(smallest,arr[i]);
return smallest;
}
public int largest(){
int largest=0;
for(int i=0;i<arr.length;i++)
largest=Math.max(largest,arr[i]);
return largest;
}
public int sum(){
int sum=0;
for(int i=0;i<arr.length;i++)
sum+=arr[i];
return sum;
}//main
public static void main(String [] args){
do
{ switch(userChoice){
while( int i=0;i<arr.length;i++)
}
case 1:System.out.println("Enter the smallest number for list1");
System.out.println("Enter the largest number for list1");
break;
case 2:System.out.println("Smallest of list1="+list1.smallest());
System.out.println("Largest of list1="+list1.largest());
break;
case 3:System.out.println("Smallest of list2="+list2.smallest());
System.out.println("Largest of list2="+list2.largest());
break;
case 4:public void display(){
for(int i=0;i<arr.length;i++)
System.out.println(arr[i]+"");
System.out.println();
}
case 5:2:System.out.println("Smallest of list1="+list1.smallest());
System.out.println("Largest of list1="+list1.largest());
break;
System.out.println("Smallest of list2="+list2.smallest());
System.out.println("Largest of list2="+list2.largest());
breal;
case 6: //is should be the quit i dont how to make it
I hope someone can help me figured it out..
thanks all..
churva....