Question

Whenever I try to run this program a window appears with Class not Found in Main...

Whenever I try to run this program a window appears with Class not Found in Main project. Thanks in Advance.

*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Assignment10;

/**
*
* @author goodf
*/
public class Assignment10{

public class SimpleGeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
  
/** Construct a default geometric object */
public SimpleGeometricObject() {
dateCreated = new java.util.Date();
}

/** Construct a geometric object with the specified color
* and filled value */
public SimpleGeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}

/** Return color */
public String getColor() {
return color;
}

/** Set a new color */
public void setColor(String color) {
this.color = color;
}

/** Return filled. Since filled is boolean,
its get method is named isFilled */
public boolean isFilled() {
return filled;
}

/** Set a new filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
  
/** Get dateCreated */
public java.util.Date getDateCreated() {
return dateCreated;
}
  
/** Return a string representation of this object */
public String toString() {
return "created on " + dateCreated + "\ncolor: " + color +
" and filled: " + filled;
}
}

  

public static class Square extends SimpleGeometricObject {
private double side;
public Square()
{
side=0;
}
public Square(double s){
super();
side=s;
}
public double getSide(){
return side;
}
public void setSide(double s){
side=s;
}
public double getArea(){
return (side*side);
}
public double getPerimeter(){
return(4*side);   
}
  
  


  
  
  
public static void Assignment10(String[] args) {
Square rectangle = new Square();
rectangle.setSide(30);
rectangle.setColor("White");
rectangle.setFilled(true);
System.out.println("Color: " + rectangle.getColor() + "Date Created: " + rectangle.getDateCreated() + "Filled: " + rectangle.isFilled()+
"Area: "+rectangle.getArea()+"Perimeter: "+rectangle.getPerimeter());
  
  
// TODO code application logic here
}
}

Homework Answers

Answer #1

If you have any doubts, please ask in the comments, I will try to solve it as soon as possible. If you find my answer helpful, do UPVOTE.Thanks

The corrected code is given below:

Assignment10.java

class SimpleGeometricObject {

private String color = "white";

private boolean filled;

private java.util.Date dateCreated;

  

/** Construct a default geometric object */

public SimpleGeometricObject() {

dateCreated = new java.util.Date();

}

/** Construct a geometric object with the specified color

* and filled value */

public SimpleGeometricObject(String color, boolean filled) {

dateCreated = new java.util.Date();

this.color = color;

this.filled = filled;

}

/** Return color */

public String getColor() {

return color;

}

/** Set a new color */

public void setColor(String color) {

this.color = color;

}

/** Return filled. Since filled is boolean,

its get method is named isFilled */

public boolean isFilled() {

return filled;

}

/** Set a new filled */

public void setFilled(boolean filled) {

this.filled = filled;

}

  

/** Get dateCreated */

public java.util.Date getDateCreated() {

return dateCreated;

}

  

/** Return a string representation of this object */

public String toString() {

return "created on " + dateCreated + "\n color: " + color +

" and filled: " + filled;

}

}

  

class Square extends SimpleGeometricObject {

private double side;

public Square()

{

side=0;

}

public Square(double s){

super();

side=s;

}

public double getSide(){

return side;

}

public void setSide(double s){

side=s;

}

public double getArea(){

return (side*side);

}

public double getPerimeter(){

return(4*side);   

}

}

public class Assignment10{

public static void main(String[] args) {

Square rectangle = new Square();

rectangle.setSide(30);

rectangle.setColor("White");

rectangle.setFilled(true);

System.out.println("Color: " + rectangle.getColor() + " Date Created: " + rectangle.getDateCreated() + " Filled: " + rectangle.isFilled()+

" Area: "+rectangle.getArea()+" Perimeter: "+rectangle.getPerimeter());

  

// TODO code application logic here

}

}

Code Snippet:

Note: There can be only one public class in a java file with the same as file name.

main function was missing

Output:

The code is running proprly now. I have attached the output

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Attached is the file GeometricObject.java. Include this in your project, but do not change. Create a...
Attached is the file GeometricObject.java. Include this in your project, but do not change. Create a class named Triangle that extends GeometricObject. The class contains: Three double fields named side1, side2, and side3 with default values = 1.0. These denote the three sides of the triangle A no-arg constructor that creates a default triangle A constructor that creates a triangle with parameters specified for side1, side2, and side3. An accessor method for each side. (No mutator methods for the sides)...
How do I make this: public class Country {     private String name;     private double area;     private...
How do I make this: public class Country {     private String name;     private double area;     private int population;     public Country(String name, double area, int population) {         this.name = name;         this.area = area;         this.population = population;     }     public double getPopulationDensity() {         return population / area;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public double getArea() {         return area;     }     public void setArea(double area) {         this.area = area;     }     public int getPopulation()...
I am not sure what I am doing wrong in this coding. I keep getting this...
I am not sure what I am doing wrong in this coding. I keep getting this error. I tried to change it to Circle2D.java but it still comes an error: Compiler error: class Circle2D is public, should be declared in a file named Circle2D.java public class Circle2D { public class Exercise10_11 { public static void main(String[] args) {     Circle2D c1 = new Circle2D(2, 2, 5.5);     System.out.println("area: " + c1.getArea());     System.out.println("perimeter: " + c1.getPerimeter());     System.out.println("contains(3, 3): "...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative sort that sorts the vehicle rentals by color in ascending order (smallest to largest) Create a method to binary search for a vehicle based on a color, that should return the index where the vehicle was found or -1 You are comparing Strings in an object not integers. Ex. If the input is: brown red white blue black -1 the output is: Enter the...
Write an interface Shape with methods getShapeName and getPerimeter. Write classes called Square, Rectangle, Circle and...
Write an interface Shape with methods getShapeName and getPerimeter. Write classes called Square, Rectangle, Circle and Triangle that implement the interface. Supply the proper parameters to the Square, Rectangle, Triangle and Circle constructors such that the perimeter can be calculated. Run THRou JDK compiler please Sample code: //Save this in Shape.java public interface Shape{ public double getPerimeter(); public String getShapeName(); } //Save this in Triangle.java public class Triangle implements Shape{ private double side1; private double side2; Triangle(double length1, double length2,...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML As a review, Here are some links to some explanations of UML diagrams if you need them. • https://courses.cs.washington.edu/courses/cse403/11sp/lectures/lecture08-uml1.pdf (Links to an external site.) • http://creately.com/blog/diagrams/class-diagram-relationships/ (Links to an external site.) • http://www.cs.bsu.edu/homepages/pvg/misc/uml/ (Links to an external site.) However you ended up creating the UML from HW4, your class diagram probably had some or all of these features: • Class variables: names, types, and...
What is the output of the following Java program? public class Food {     static int...
What is the output of the following Java program? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { s = flavor; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         pepper.setFlavor("spicy");         System.out.println(pepper.getFlavor());     } } Select one: a. sweet b. 1 c. The program does not compile. d. 2 e. spicy...
public class Bicycle { // Instance variables (fields) private String ownerName; private int licenseNumber; // Constructor...
public class Bicycle { // Instance variables (fields) private String ownerName; private int licenseNumber; // Constructor public Bicycle( String name, int license ) { ownerName = name;    licenseNumber = license; } // Returns the name of the bicycle's owner public String getOwnerName( ) { return ownerName; } // Assigns the name of the bicycle's owner public void setOwnerName( String name ) { ownerName = name; } // Returns the license number of the bicycle public int getLicenseNumber( ) {...
Compile and execute the application. You will discover that is has a bug in it -...
Compile and execute the application. You will discover that is has a bug in it - the filled checkbox has no effect - filled shapes are not drawn. Your first task is to debug the starter application so that it correctly draws filled shapes. The bug can be corrected with three characters at one location in the code. Java 2D introduces many new capabilities for creating unique and impressive graphics. We’ll add a small subset of these features to the...
Please solve this problem in java. import java.util.Arrays; public class PriorityQueue { /* This class is...
Please solve this problem in java. import java.util.Arrays; public class PriorityQueue { /* This class is finished for you. */ private static class Customer implements Comparable { private double donation; public Customer(double donation) { this.donation = donation; } public double getDonation() { return donation; } public void donate(double amount) { donation += amount; } public int compareTo(Customer other) { double diff = donation - other.donation; if (diff < 0) { return -1; } else if (diff > 0) { return...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT