MjM8082's Profile User Rating: -----

Reputation: 4 Apprentice
Group:
Members
Active Posts:
22 (0.02 per day)
Joined:
17-August 11
Profile Views:
2,681
Last Active:
User is offline Nov 10 2012 11:58 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
XBox
Your Car:
Nissan
Dream Kudos:
0
Icon   MjM8082 Confused

Posts I've Made

  1. In Topic: Exception Handling Problems

    Posted 25 Sep 2012

    Thanks for the reply. I fixed the problem... what I used what this...




    private static void checkNumber(int num) throws invalidNumber				//run the check activation exception
    {
    	Scanner keyboard = new Scanner(System.in);
    	
    	if(String.valueOf(num).length()!=5)
      {
    		throw new invalidNumber("invalid number");
      }
    	else  {
    		
    		cardNum.add(num);
    
    		System.out.println("Thank you! You're card number is " +cardNum);
    
    		System.out.println("Type 'c' to go back to main menu.");
    		String value = keyboard.next();
    		
    		if(value.equalsIgnoreCase("c")){
    			menu();
    	
    }
    
    




    and on the try catch code I used this...


    int num = input.nextInt(); 
    			checkNumber(num);
    
  2. In Topic: Exception Handling Problems

    Posted 23 Sep 2012

    Could you give me an example, I'm kinda confused here.
  3. In Topic: Exception Handling Problems

    Posted 23 Sep 2012

    Okay I used:

    
    if (input.nextInt() == 5){
    
    System.out.println("Works!");
    
    }
    
    else{
    		
     	 throw new invalidNumber("invalid number");
     }
    
    
    


    But now every time I enter a number it sends the error no matter what. It always says invalid number even if I type in 5 digits.

    I think I might need to check if the length is 5 digits not if the number is == 5 . Not sure how though?
  4. In Topic: How to use a LinkedList correctly?

    Posted 8 Sep 2012

    Figured it out...


    public int getIndexForName(String name) {
    	    if (stadiumNames.contains(name)) {
    	        int total = 0;
    	        for (int i = 0 ; i < stadiumNames.size() ; i++)
    	            if (stadiumNames.get(i).equals(name))
    	            total += gameRevenue.get(i);
    	            System.out.println("The total revenue is: " + total);
    	            System.exit(0);
    	    }
    	    return -1;
    	}
    


    Thanks everyone for the help!

    I left you all some positive rep!
  5. In Topic: How to use a LinkedList correctly?

    Posted 8 Sep 2012

    So something like this...


    	public int getIndexForName(String name) {
    		
    		if(stadiumNames.contains(name)){
    			System.out.println("The total revenue is: " +gameRevenue.get(0));
    			System.exit(0);
    		}
    		
    		
    		return -1;
    		
    	}
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
United States

Contact Information

E-mail:
Private
AIM:
AIM  mjm8082
Website URL:
Website URL  http://www.projectmjm.com

Friends

Comments

Page 1 of 1
  1. Photo

    MjM8082 Icon

    06 Sep 2012 - 22:24
    Ignore the reputation, must of been for something dumb I might of done a long time ago!
Page 1 of 1