jdam's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Members
Active Posts:
29 (0.04 per day)
Joined:
26-June 12
Profile Views:
490
Last Active:
User is offline Jul 30 2012 05:43 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   jdam has not set their status

Posts I've Made

  1. In Topic: Many Thanks!

    Posted 25 Jul 2012

    Dogstopper,
    Sorry about that! Thank you!
  2. In Topic: Boolean Method and Formatting Error

    Posted 15 Jul 2012

    View Postpbl, on 15 July 2012 - 08:13 PM, said:

    'fe' was not the problem.
    It was %f followed by the letter "e"
    the problem was the % before the \n


    got it, thanks. I didn't have that before and added it at one point to see if it would fix it, then I didn't remove it again. Thank you for the help!
  3. In Topic: Boolean Method and Formatting Error

    Posted 15 Jul 2012

    View Postpbl, on 15 July 2012 - 07:53 PM, said:

    final String bodySpace = "%-12s%-12d%-10fe%\n";

    should be

    final String bodySpace = "%-12s%12d%10f\n";


    pbl,
    I compiled it with this format, I still get the same problem. I fixed my typo with the 'fe' still gives me the same problem. Thank you for looking at it! :)
  4. In Topic: Boolean Method and Formatting Error

    Posted 15 Jul 2012

    x68zeppelin80x,
    Still have the same error, I tried e, d, f, s and so on. I am wondering if it isn't really in:

     final String bodySpace = "%-12s%-12d%-10e%\n";
    


    but maybe here, and I'm not sure how to fix it:

    if((!isVaccinated) && (age >= 4)){
       
        System.out.println("The un-vaccinated hamsters over 4 months old are: ");
        System.out.printf(headerSpace, "Name: ", "Age: ", "Weight: ");
        System.out.printf(bodySpace, myHamster1.getName(), myHamster1.getAge(), myHamster1.getWeight());
        System.out.printf(bodySpace, myHamster2.getName(), myHamster2.getAge(), myHamster2.getWeight());
        System.out.printf(bodySpace, myHamster3.getName(), myHamster3.getAge(), myHamster3.getWeight());
       
      }else
        {
        System.out.print("There are no un-vaccinated hamsters over 4 months old!");
        }
    
    
  5. In Topic: Boolean Method and Formatting Error

    Posted 15 Jul 2012

    Alright, one more for this one... it is the "formatting error" Here is the error:

    The un-vaccinated hamsters over 4 months old are:
    Name: Age: Weight:
    Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '
    '
    at java.util.Formatter.checkText(Formatter.java:2503)
    at java.util.Formatter.parse(Formatter.java:2485)
    at java.util.Formatter.format(Formatter.java:2414)
    at java.io.PrintStream.format(PrintStream.java:920)
    at java.io.PrintStream.printf(PrintStream.java:821)
    at HamsterDriver.main(HamsterDriver.java:91)

    and here is my updated code (from the last time I posted, yes still no array, that will be in a whole different code I will not be submitting and will be used for practice!)

    import java.util.*;
    public class HamsterDriver
    {
     public static void main (String[] args)
     {
      Scanner input = new Scanner(System.in); 
      final String headerSpace = "%-12s%-12s%-10s\n";
      final String bodySpace = "%-12s%-12d%-10d%\n";
    
      //object declanation
      Hamster myHamster1;
      Hamster myHamster2;
      Hamster myHamster3;
    
      //object instantiations
      myHamster1 = new Hamster(); 
      myHamster2 = new Hamster();
      myHamster3 = new Hamster();
        
      String name;            // local variable for hamsters’ names 
      int age;                // local variable for hamsters’ ages
      double weight;          // local variable for hamsters’ weights
      String color;           // local variable for hamsters’ colors
      boolean isVaccinated;  // local variable for hamsters’ vaccinations
    
      
       System.out.println("Enter the name of Hamster1:");
        name = input.next();
       System.out.println("Enter the age (in months) of Hamster1:");
        age = input.nextInt();
       System.out.println("Enter the weight (in pounds) of Hamster1:");
        weight = input.nextDouble();
       System.out.println("Enter the color of Hamster1:");
        color = input.next();
       System.out.println("Is Hamster1 vaccinated? true or false");
        isVaccinated = input.nextBoolean();
    
        //store Hamster1 information   
        myHamster1.setName(name);
        myHamster1.setAge(age);
        myHamster1.setWeight(weight);
        myHamster1.setColor(color);
        myHamster1.setisVaccinated(isVaccinated);
    
       System.out.println("Enter the name of Hamster2:");
        name = input.next();
       System.out.println("Enter the age (in months) of Hamster2:");
        age = input.nextInt();
       System.out.println("Enter the weight (in pounds) of Hamster2:");
        weight = input.nextDouble();
       System.out.println("Enter the color of Hamster2:");
        color = input.next();
       System.out.println("Is Hamster2 vaccinated? true or false");
        isVaccinated = input.nextBoolean();
    
       //store Hamster2 information
       myHamster2.setName(name);
       myHamster2.setAge(age);
       myHamster2.setWeight(weight);
       myHamster2.setColor(color);
       myHamster2.setisVaccinated(isVaccinated);
       
       System.out.println("Enter the name of Hamster3:");
        name = input.next();
       System.out.println("Enter the age (in months) of Hamster:");
        age = input.nextInt();
       System.out.println("Enter the weight (in pounds) of Hamster3:");
        weight = input.nextDouble();
       System.out.println("Enter the color of Hamster3:");
        color = input.next();
       System.out.println("Is Hamster3 vaccinated? true or false");
        isVaccinated = input.nextBoolean();
     
        //store Hamster3 information   
        myHamster3.setName(name);
        myHamster3.setAge(age);
        myHamster3.setWeight(weight);
        myHamster3.setColor(color);
        myHamster3.setisVaccinated(isVaccinated);
    
      if((!isVaccinated) && (age >= 4)){// this is where I believe the error is, in this section of code
       
        System.out.println("The un-vaccinated hamsters over 4 months old are: ");
        System.out.printf(headerSpace, "Name: ", "Age: ", "Weight: ");
        System.out.printf(bodySpace, myHamster1.getName(), myHamster1.getAge(), myHamster1.getWeight());
        System.out.printf(bodySpace, myHamster2.getName(), myHamster2.getAge(), myHamster2.getWeight());
        System.out.printf(bodySpace, myHamster3.getName(), myHamster3.getAge(), myHamster3.getWeight());
       
      }else
        {
        System.out.print("There are no un-vaccinated hamsters over 4 months old!");
        }
     }// end main
    } //end HamsterDriver
    
    

My Information

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

Contact Information

E-mail:
Private

Friends

jdam hasn't added any friends yet.

Comments

jdam has no profile comments yet. Why not say hello?