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
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with the default values denoted by dataType name : defaultValue - String animal : empty string - int lapsRan : 0 - boolean resting : false - boolean eating : false - double energy : 100.00 For the animal property implement both getter/setter methods. For all other properties implement ONLY a getter method Now implement the following constructors: 1. Constructor 1 – accepts a String...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {       ...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {        Stack<Integer> new_stack = new Stack<>();/* Start with the empty stack */        Scanner scan = new Scanner(System.in);        int num;        for (int i=0; i<10; i++){//Read values            num = scan.nextInt();            new_stack.push(num);        }        int new_k = scan.nextInt(); System.out.println(""+smallerK(new_stack, new_k));    }     public static int smallerK(Stack s, int k) {       ...
Java Program: You will be inserting values into a generic tree, then printing the values inorder,...
Java Program: You will be inserting values into a generic tree, then printing the values inorder, as well as printing the minimum and maximum values in the tree. Given main(), write the methods in the 'BSTree' class specified by the // TODO: sections. There are 5 TODOs in all to complete. Ex: If the input is like ferment bought tasty can making apples super improving juice wine -1 the output should be: Enter the words on separate lines to insert...
Here is my java code, I keep getting this error and I do not know how...
Here is my java code, I keep getting this error and I do not know how to fix it: PigLatin.java:3: error: class Main is public, should be declared in a file named Main.java public class Main { ^ import java.io.*; public class Main { private static BufferedReader buf = new BufferedReader( new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { String english = getString(); String translated = translate(english); System.out.println(translated); } private static String translate(String s) { String latin =...
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...
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...
Hello. I have an assignment that is completed minus one thing, I can't get the resize...
Hello. I have an assignment that is completed minus one thing, I can't get the resize method in Circle class to actually resize the circle in my TestCircle claass. Can someone look and fix it? I would appreciate it! If you dont mind leaving acomment either in the answer or just // in the code on what I'm doing wrong to cause it to not work. That's all I've got. Just a simple revision and edit to make the resize...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
In Java Let’s say we’re designing a Student class that has two data fields. One data...
In Java Let’s say we’re designing a Student class that has two data fields. One data field, called id, is for storing each student’s ID number. Another data field, called numStudents, keeps track of how many Student objects have been created. For each of the blanks, indicate the appropriate choice. id should be   public/private   and   static/not static . numStudents should be   public/private   and   static/not static . The next three questions use the following class: class Counter {     private int...
The following program creates a linked list which contains 5 links. Add a method called doubleValue()...
The following program creates a linked list which contains 5 links. Add a method called doubleValue() to the LinkedList class. The doubleValue() method must double the value of the number data field in each link. Add the required code to the main() method to call the doubleValue() method and display the revised list. public class Link { private int number; private Link next;      public Link(int x) { number = x; }    public void displayLink() { System.out.println("The number is:...