Question

In: Computer Science

this code still shows that it still has an syntax error in it can you please...

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());
}

}

Solutions

Expert Solution

//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


Related Solutions

The following code has some syntax error. Please fixed the error. Besides, I want the output...
The following code has some syntax error. Please fixed the error. Besides, I want the output in ASCII characters. Please give me the corrected code along with the screenshot of the output. def cbc_dec(ys): int xs = [] int iv = ("0XAA", 16) #in decimal int key = ("0X08", 16) int x0 = chr(((163 * (int (ys[0], 16) - key)) % 256) ^ iv) xs.append(x0) for i in range (1, len(ys)): int xi = chr((( 163 * (int (ys[i], 16)...
#1. There is an error in the code. Not a grave error – the sort still...
#1. There is an error in the code. Not a grave error – the sort still works correctly. What is the error? ( no code needs to be added or deleted to correct the error ) #2. The algorithm can be improved in terms of memory use. How? ( no new code is necessary ) # 3. What do lines 26-27 do ? ( copying arryptr into temp is not the complete answer. Be specific ) #4.What do lines 30-31...
For each of the following Visual Basic code snippets, identify the syntax error.   If intX >...
For each of the following Visual Basic code snippets, identify the syntax error.   If intX > 100   lblResult.Text = "Invalid Data" End If   Dim str As String = "Hello" Dim intLength As Integer intLength = Length(str) If intZ < 10 Then   lblResult.Text = "Invalid Data"   Dim str As String = "123" If str.IsNumeric Then   lblResult.Text = "It is a number." End If   Select Case intX   Case < 0     lblResult.Text = "Value too low."   Case > 100     lblResult.Text = "Value too high."   Case Else     lblResult.Text = "Value...
Look at the C code below. Identify the statements that contain a syntax error OR logical...
Look at the C code below. Identify the statements that contain a syntax error OR logical error. Evaluate each statement as if all previous statements are correct. Select all that apply                 #include <stdio>                 Int main()                 {                                 Float webbing;                                 Puts(“Please enter the amount of webbing per cartridge: “)                                 Scanf(“%f”, webbing);                                 Printf(“You entered: “+ webbing + “\n”);                                 Return 0;                 } Answers:                 Including the library for I/O                 Declaring a variable                 Writing...
Can you please check for the error in my code?: #data object is created text_data =...
Can you please check for the error in my code?: #data object is created text_data = {"the_final_output": [{"abs": ""}, {"abs": ""}, ..., {"abs": ""}]} #a list is created main_terms = [] #iterating every data in the_final_output for i in range(len(text_data["the_final_output"]): blob = TextBlob(text_data["the_final_output"][i]["abs"]) main_terms.append(blob.polarity)    #sentiment analysis sorts the text into positive, neutral, and negative. tp = sum(main_terms) #if tp is less than 0, it's negative if tp < 0: print("Negative") #if tp is greater than 0, it's positive elif...
C++ : Find the syntax errors in the following program. For each syntax error, fix it...
C++ : Find the syntax errors in the following program. For each syntax error, fix it and add a comment at the end of the line explaining what the error was. #include <iostream> #include <cmath> using namespace std; int main(){ Double a, b, c; 2=b; cout<<"Enter length of hypotenuse"<<endl; cin>>c>>endl; cout>>"Enter length of a side"<<endl; cin>>a; double intermediate = pow(c, 2)-pow(a, 2); b = sqrt(intermediate); cout<<"Length of other side is:" b<<endline; return 0; }
Please identify each error present, explain the type of error (syntax/logic/run-time), and provide a fix which...
Please identify each error present, explain the type of error (syntax/logic/run-time), and provide a fix which changes the given code as little as possible (i.e. don't rewrite the whole thing; just point out what is wrong and a fix for it). 5) // Assign a grade based on the score char score; cin>>score; if score < 0 && score > 100     cout<<"The score entered is invalid"<<endl; if (score <= 90)     grade = "A"; if (score <= 80)    ...
Can you correct my database syntax so it works on rextester or dbfiddle. Error(s), warning(s): Column,...
Can you correct my database syntax so it works on rextester or dbfiddle. Error(s), warning(s): Column, parameter, or variable #2: Cannot find data type VARCHAR2. CREATE TABLE Supplier (    SuppNo        CHAR(8),    SuppName   VARCHAR2(30) CONSTRAINT SuppNameRequired NOT NULL,    SuppEMail   VARCHAR2(50),    SuppPhone   CHAR(14),    SuppURL       VARCHAR2(100),     SuppDiscount   DECIMAL(3,3), CONSTRAINT PKSupplier PRIMARY KEY (SuppNo) ); INSERT INTO supplier    (SuppNo,SuppName,SuppEmail,SuppPhone,SuppURL,SuppDiscount)    VALUES('S2029929','ColorMeg, Inc.','[email protected]','(720)444-1231','www.colormeg.com',0.10); INSERT INTO supplier    (SuppNo,SuppName,SuppEmail,SuppPhone,SuppURL,SuppDiscount)    VALUES('S3399214','Connex','[email protected]','(206)432-1142','www.connex.com',0.12); INSERT INTO supplier    (SuppNo,SuppName,SuppEmail,SuppPhone,SuppURL,SuppDiscount)...
It shows me that 1 error exists in this code but I didn't know how to...
It shows me that 1 error exists in this code but I didn't know how to fix this error so if you can help I will appreciate it. Language C++. Code: #include <iostream> #include <string> #include <iterator> #include <fstream> #include <sstream> #include <cstdlib> #include <set> using namespace std; class Book { private: string BookId; string BookISBN; string Publisher; int PublisherYear; double Price; int Quantity; string Author; public: string SetBookId(); string SetBookISBN(); string SetPublisher(); int SetPublisherYear(); double SetPrice(); int SetQuantity(); string...
Please Fix Syntax Error import java.util.Scanner; public class SalaryCalc {    double Rpay = 0, Opay...
Please Fix Syntax Error import java.util.Scanner; public class SalaryCalc {    double Rpay = 0, Opay = 0;    void calPay(double hours, double rate) {        if (hours <= 40) {            Rpay = hours * rate;            Opay = 0;        } else {            double Rhr, Ohr;            Rhr = 40;            Ohr = hours - Rhr;            Rpay = Rhr * rate;   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT