/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package plantnursery; import java.util.Scanner; /** * * @author Kl2eativ */ public class Plant { boolean fragile; public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("Is it fragile? Yes or No."); boolean f = s.nextBoolean(); } @Override public String toString(){ return "The Height of this plant is:" + heightInFeet + " . The common name is " + commonName + " . The scientific name is :" + scientificName + " It's price is:" + price + " and it is " + fragile; }
When I execute the program and when it asks me if its fragile or no, w.e i type i get this error:
[Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:840)
at java.util.Scanner.next(Scanner.java:1461)
at java.util.Scanner.nextBoolean(Scanner.java:1756)
at plantnursery.Plant.main(Plant.java:30)
Java Result: 1]
and then my tostring does not execute... Help is appriciated before 10, or I will have to submit it like this.