Question: package com.test; import java.util.Scanner; public class Cycle { private double numberOfWheels; private double weight; public Cycle(double numberOfWheels, double weight) { super(); this.numberOfWheels = numberOfWheels; this.weight

package com.test; import java.util.Scanner; public class Cycle { private double numberOfWheels; private double weight; public Cycle(double numberOfWheels, double weight) { super(); this.numberOfWheels = numberOfWheels; this.weight = weight; } public double getNumberOfWheels() { return numberOfWheels; } public double getWeight() { return weight; } public void setNumberOfWheels(double numberOfWheels) { this.numberOfWheels = numberOfWheels; } public void setWeight(double weight) { this.weight = weight; } public static void main(String[] args) throws NegativeException { String wheels,w; double NoOfWheel = 0, weight = 0; Scanner sc = new Scanner(System.in); System.out.println("Please enter number of wheels"); wheels = sc.next(); try{ NoOfWheel = Double.parseDouble(wheels); if(NoOfWheel < 0) throw new NegativeException(); }catch (NegativeException e) { // TODO: handle exception } catch (NumberFormatException ex) { System.out.println("Entered no of wheel is not double exception "+ ex); } w = sc.next(); try{ weight = Double.parseDouble(w); if(weight < 0) throw new NegativeException(); }catch (NegativeException e) { // TODO: handle exception } catch (NumberFormatException ex) { System.out.println("Entered weight is not double exception "+ ex); } Cycle c = new Cycle(NoOfWheel, weight); } } //NegativeException.java package com.test; class NegativeException extends Exception{ public NegativeException() { System.out.println("Number is negative"); } public NegativeException(String message) { System.out.println(message); } }

Need help with the code since wont run due to enum errors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!