fork download
  1. import java.util.*;
  2. public class Car
  3. {
  4. private double hour;
  5. private double charge;
  6.  
  7.  
  8. public Car() //default constructor
  9. {
  10. hour = 0.0;
  11.  
  12. charge = 0.0;
  13. }
  14.  
  15. public Car(double theHour, double theCharge)
  16. {
  17. this.hour = theHour;
  18. this.charge = theCharge;
  19.  
  20. if (hour>24.0 || hour<0.00)
  21. throw new IllegalArgumentException("Out of Range");
  22.  
  23. }
  24. public double gethour()
  25. {
  26. return hour;
  27. }
  28.  
  29. public double getcharge()
  30. {
  31. return charge;
  32.  
  33. }
  34.  
  35.  
  36. public String toString()
  37. {
  38.  
  39. return hour + "" + charge;
  40.  
  41. }
  42. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:2: error: class Car is public, should be declared in a file named Car.java
public class Car
       ^
1 error
stdout
Standard output is empty