Question

In: Computer Science

can you please look at the following code and fix it for me so that it...

can you please look at the following code and fix it for me so that it does not have any syntax errors. also can you tell me what was fixed

/**
* Driver program to demonstrate calling methods of Client class.
*
* @author Doyt Perry/Tina Comston
* @version Fall 2019
*/
public class ClientDemo
{
public static void main()
{
/**
* main method - makes this an executable program.
*/
// 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

class Client {

    private String firstName;
    private String lastName;
    private int age;
    private int height;
    private int weight;

    public Client() {
    }

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

    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 "firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' +
                ", age=" + age + ", height=" + height + ", weight=" + weight;
    }
}

/**
 * Driver program to demonstrate calling methods of Client class.
 *
 * @author Doyt Perry/Tina Comston
 * @version Fall 2019
 */
public class ClientDemo {
    /**
     * 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 display 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());
    }
}


Related Solutions

I wrote this code and it produces a typeError, so please can you fix it? import...
I wrote this code and it produces a typeError, so please can you fix it? import random def first_to_a_word(): print("###### First to a Word ######") print("Instructions:") print("You will take turns choosing letters one at a time until a word is formed.") print("After each letter is chosen you will have a chance to confirm whether or not a word has been formed.") print("When a word is formed, the player who played the last letter wins!") print("One of you has been chosen...
I need to fix this code, and could you please tell me what was the problem...
I need to fix this code, and could you please tell me what was the problem options 1 and 9 don't work #include <stdio.h> #include <time.h> #include <stdlib.h> // generate a random integer between lower and upper values int GenerateRandomInt(int lower, int upper){     int num =(rand()% (upper - lower+1))+lower;     return num; } // use random numbers to set the values of the matrix void InitializeMatrix(int row, int column, int dimension, int mat[][dimension]){     for(int i =0; i<row; i++){...
Can you fix to me this code plz I just want to print this method as...
Can you fix to me this code plz I just want to print this method as the reverse. the problem is not printing reverse. public void printBackward() {               Node curr = head;        Node prev = null;        Node next = null;               System.out.print("\nthe backward of the linkedlist is: ");               while(curr != null) {            next = curr.next;            curr.next = prev;   ...
Please fix this python code for me DOWN_PAYMENT_RATE = 0.10 ANNUAL_INTEREST_RATE = 0.12 MONTHLY_PAYMENTS_RATE = 0.05...
Please fix this python code for me DOWN_PAYMENT_RATE = 0.10 ANNUAL_INTEREST_RATE = 0.12 MONTHLY_PAYMENTS_RATE = 0.05 purchasePrice = float(input("Enter the purchase price: ")) month = 1 payment = purchasePrice * MONTHLY_PAYMENTS_RATE startingBalance = purchasePrice print("\n%s%19s%18s%19s%10s%17s" % ("Month", "Starting Balance", "Interest to Pay", "Principal to Pay", "Payment", "Ending Balance")) while startingBalance > 0:     interestToPay = startingBalance * ANNUAL_INTEREST_RATE / 12     principalToPay = payment - interestToPay     endingBalance = startingBalance - payment     print("%2d%16.2f%16.2f%18.2f%18.2f%15.2f" % (month, startingBalance, interestToPay, principalToPay, payment,...
Can you fix this code please. the removing methods id no doing anything. this is java...
Can you fix this code please. the removing methods id no doing anything. this is java code import java.util.NoSuchElementException; public class DoublyLinkedList<E> {    public int size;    public Node head;    public Node tail;             @Override    public boolean isEmpty() {               return size == 0;    }    @Override    public int getSize() {               return 0;    }    @Override    public void addAtFront(E element) {       ...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class Main { static int comparisons; static int exchanges; // Recursive function to perform insertion sort on sub-array arr[i..n] public static void insertionSort(int[] arr, int i, int n) { int value = arr[i]; int j = i; // Find index j within the sorted subset arr[0..i-1] // where element arr[i] belongs while (j > 0 && arr[j - 1] > value) { arr[j] = arr[j...
Can you fix the code and comment the fix Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -39 at...
Can you fix the code and comment the fix Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -39 at CaesarCipher.encrypt(CaesarCipher.java:28) at CaesarCipher.main(CaesarCipher.java:52) public class CaesarCipher{     char[] encoder = new char[52];     char[] decoder = new char[52];      public CaesarCipher(int rotation)      {        for(int k=0 ; k < 26 ; k++)        {            encoder[k] = (char) ('A' + (k + rotation) % 26);            decoder[k] = (char) ('A' + (k - rotation + 26) % 26);        }        for(int j...
fix this code in python and show me the output. do not change the code import...
fix this code in python and show me the output. do not change the code import random #variables and constants MAX_ROLLS = 5 MAX_DICE_VAL = 6 #declare a list of roll types ROLLS_TYPES = [ "Junk" , "Pair" , "3 of a kind" , "5 of a kind" ] #set this to the value MAX_ROLLS pdice = [0,0,0,0,0] cdice = [0,0,0,0,0] #set this to the value MAX_DICE_VAL pdice = [0,0,0,0,0,0] cdice = [0,0,0,0,0,0] #INPUT - get the dice rolls i...
Can someone tell me how to fix warning msg in my code of C ++? I...
Can someone tell me how to fix warning msg in my code of C ++? I got run-time error for this question please help me asap! Errors are: In function 'void bfs(int, int)': warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < adj[pppp].size(); j++){ ^ In function 'int main()': warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d %d %d", &a, &q, &c, &N, &m); ^...
Can you please take this code and just rewrite it so it can be easily be...
Can you please take this code and just rewrite it so it can be easily be able to put into a complier. in java Implementation of above program in java: import java.util.HashMap; import java.util.Scanner; import java.util.Map.Entry; public class Shopping_cart {       static Scanner s= new Scanner (System.in);    //   declare hashmap in which key is dates as per mentioned and Values class as value which consists all the record of cases    static HashMap<String,Item> map= new HashMap<>();    public...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT