Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: exception use array (help me)

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default exception use array (help me)

    Please make a simulation program of Student Mark List with these following descriptions:
    1. The program consists of 4 menu:
    • 1. Input Student
    • 2. See All Data
    • 3. Edit Data
    • 4. Exit
    2. If user choose menu 1, then user will be asked to input number of student in the list. Validate the number of student must be between 1 and 5.
    3. Then the program will be asked user to input Student Id, Student Name and Student Mark as many as the number of student that user input before. Validate:
    • Student Id must be 10 characters long.
    • Student Name must be filled.
    • Student Mark must be between 0 and 100.


    4. If user choose menu 2, then:
    • Show the student data from the list include student number.
    • Then user will be asked to choose the student number of the student to showing the completed student data.


    5. If user choose menu 3, then:
    • Show the student data from the list include student number.
    • Then user will be asked to choose the student number of the student to showing the completed student data which user wants to

    edit.
     Then user will be asked to input Student Id, Student Name and Student mark with the validation same as before.


    please, check my coding


    [/COLOR]
    import java.util.*;
    import java.io.*;
     
    public class J1601226535_07{
    	public static void main (String[]args){
    		Scanner in = new Scanner(System.in);
    		int number = 5;//0-4
    		int choice;
    		int student, ID, Name;
    		boolean flag;
     
    		do{
    			flag = false; // untuk nilai yg minus atau salah
    				try{
    				number = in.nextInt();
    				}catch(InputMismatchException e){
    						flag=true;
    						System.out.println("Inputan harus bilangan bulat");
    						in.nextLine();
    				}
    	}while(flag);
     
     
    			System.out.println("\t\t Student Mark List \t\t");
    			System.out.println ("1. Input Student");
    			System.out.println("2. See All Data");
    			System.out.println("3. Edit Data");
    			System.out.println("4. Exit");
     
    			do{
    				System.out.print("Input Your Choice [1-4]: ");
    				choice = in.nextInt();
    			}while(menu < 1 || menu > 4);
    				switch(menu){
    					case 1 : System.out.println(How many student[1-5] ? ); break;
    					case 2 : System.out.println(See All Data); break;
    					case 3 : System.out.println(Edit Data); break;
    						}
    			}while(menu != 4);
     
     
    					System.out.println("Please input data of 5 people");
    					System.out.print("1 \t Please input Student ID [10]= ");
    					ID = in.nextInt();
    					System.out.print("\t Please input Student Name\t= ");
    					Name = in.nextInt();
    					System.out.print("\t Please input Student Mark [0-100]= ");
    					System.out.print("2 \t Please input Student ID [10]= ");
    					ID = in.nextInt();
    					System.out.print("\t Please input Student Name\t= ");
    					Name = in.nextInt();
    					System.out.print("\t Please input Student Mark [0-100]= ");
    					System.out.print("3 \t Please input Student ID [10]= ");
    					ID = in.nextInt();
    					System.out.print("\t Please input Student Name\t= ");
    					Name = in.nextInt();
    					System.out.print("\t Please input Student Mark [0-100]= ");
    					System.out.print("4 \t Please input Student ID [10]= ");
    					ID = in.nextInt();
    					System.out.print("\t Please input Student Name\t= ");
    					Name = in.nextInt();
    					System.out.print("\t Please input Student Mark [0-100]= ");
    					System.out.print("5 \t Please input Student ID [10]= ");
    					ID = in.nextInt();
    					System.out.print("\t Please input Student Name\t= ");
    					Name = in.nextInt();
    					System.out.print("\t Please input Student Mark [0-100]= ");
     
    		}
    	}
    Last edited by pbrockway2; June 1st, 2013 at 12:40 AM. Reason: code tags added


Similar Threads

  1. Replies: 1
    Last Post: February 6th, 2013, 11:21 AM
  2. [SOLVED] Array Index out of bounds Exception
    By Tohtekcop in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 19th, 2012, 04:03 PM
  3. Exception when creating an array
    By Majora94 in forum Collections and Generics
    Replies: 2
    Last Post: February 23rd, 2012, 05:33 PM
  4. Array exception out of bounds
    By gabberlt in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 17th, 2011, 09:05 AM
  5. [SOLVED] Error: Null Exception on Array of classes
    By g000we in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2010, 09:14 AM