In: Computer Science
this code still shows that it still has an syntax error in it can you please fix it. I will put an error message next to the line that is wrong and needs fixed, other than that the other lines seems to be ok.
public static void main()
{
/**
* main method - makes this an executable program.
*/
public static void main("String[]args"); this is the error line
that I get and needs fixed
// create a client with placeholder values
system.out.println("Client with default information");
// create a client object using first constructor
Client client1 = new Client();
// Display information about the client
System.out.println(client1.toString());
System.out.println();
System.out.println("Create a client by providing
information");
// client last name - Jameson
// client first name - Rebecca
// client age - 32
// client height - 65
// client weight - 130
Client client2 = new Client("Jameson", "Rebecca",
32, 65, 130);
// Display information about the client
System.out.println(client2.toString());
// Display the first name
System.out.println("original first name = " +
client2.getFirstName());
// set the first name to the value Rachel
client2.setFirstName("Rachel");
// Retrieve and dislplay the client first name
System.out.println("new first name = " +
client2.getFirstName());
// Display information about the client
System.out.println(client2.toString());
// set their weight to 180
client2.setWeight(180);
// Display information about the client
System.out.println(client2.toString());
}
}
//Use this java code...It may help you
public class Client {
// client last name
private String firstName;
// client first name
private String lastName;
// client age
private int age;
// client height
private int height;
// client weight
private int weight;
//default Constructor
public Client()
{
}
//Constructor
public Client(String firstName, String lastName, int age, int height, int weight) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.height = height;
this.weight = weight;
}
//getters setters
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
@Override
public String toString() {
return "Client Name: "+firstName+" "+lastName+" age: "+age+" weight: "+weight+" height: "+height;
}
}
//==============================================
public class TestClient {
/**
* main method - makes this an executable program.
*/
public static void main(String[] args)
{
// create a client with placeholder values
System.out.println("Client with default information");
// create a client object using first constructor
Client client1 = new Client();
// Display information about the client
System.out.println(client1.toString());
System.out.println();
System.out.println("Create a client by providing information");
// client last name - Jameson
// client first name - Rebecca
// client age - 32
// client height - 65
// client weight - 130
Client client2 = new Client("Jameson", "Rebecca",
32, 65, 130);
// Display information about the client
System.out.println(client2.toString());
// Display the first name
System.out.println("original first name = " +
client2.getFirstName());
// set the first name to the value Rachel
client2.setFirstName("Rachel");
// Retrieve and dislplay the client first name
System.out.println("new first name = " +
client2.getFirstName());
// Display information about the client
System.out.println(client2.toString());
// set their weight to 180
client2.setWeight(180);
// Display information about the client
System.out.println(client2.toString());
}
}
//Output

//If you need any help regarding this solution ............ please leave a comment ....... thanks