Question: I need this code to be coded the right way... on VS code its saying Cannot find a class with the main method. please help

I need this code to be coded the right way... on VS code its saying Cannot find a class with the main method.

please help with the code or code it as least

//Godyson Blanc

//June, 24,2022

//Java as the program language

//This file contains Object

//class of a book with this construdors and attrbutes of a book

import java.lang.Class;

class Book {

private String title;

private int price;

private String author;

private String genre;

private String publisher;

private int numPages;

//the projetc requires a specific number of instances varibles of attrbuuites of a Book. Here is the instances varibles

public Book(String title, int price, String author, String genre, String publisher, int numPages) {

this.title = title;

this.price = price;

this.author = author;

this.genre = genre;

this.publisher = publisher;

this.numPages = numPages;

}

//this area is meant for this constructor and the variable instances thus is required to be input to the get instance constructored outcome for the BOOk

//The default state is initialized with this method.

public Book(String title, String author, int numPages, int price, String genre, String publisher) {

this.title = title;

this.author = author;

this.genre = genre;

this.publisher = publisher;

this.numPages = numPages;

this.price = price;

}

// Syntax... Setter and Getters of the variables instances thus As a programmer, you can choose how variables are created and modified

public String getTitle() //accessor methods for the title

{

return title;

}

public String getAuthor() //accessor methods for the author

{

return author;

}

public String getGenre() //accessor methods for the genre

{

return genre;

}

public String getPublisher() //accessor methods for the publisher

{

return publisher;

}

public int getPrice() //accessor methods for the price

{

return price;

}

public int getNumPages(){ //accessor methods for the numPages

return numPages;

}

// An object's value can be set or updated with the setter method. The syntax of a setter should be used to retrieve

// and update the value of a variable outside of the enclosing class.

public void setTitle(String title) //mutator methods for the title

{

this.title=title;

}

public void setAuthor(String author) //mutator methods for the author

{

this.author=author;

}

public void setPublisher(String publisher) //mutator methods for the publisher

{

this.publisher=publisher;

}

public void setGenre(String genre) //mutator methods for the genre

{

this.genre=genre;

}

public void setPrice(int price) { //mutator methods for the price

this.price=price;

}

public void setNumpage(int numpage) {

this.numPages =numpage;

}

// reference for this part geeksforgeeks.org/string-tostring-method-in-java/

// Using this method, we are able to return the String representation of the object.

public String toString() {

return "Title: "+title+" Publisher: "+publisher+" Author: "+author+" Price: "+price+" Numpages: "+numPages+" Genre: "+genre+" ";

}

}

Step by Step Solution

3.44 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Your Java code seems mostly correct but you may be encountering the Cannot find a class with the main method error because you havent included a main ... View full answer

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 Programming Questions!