Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a function called build person. It will not have any input parameters, bu

ID: 3788146 • Letter: C

Question

Create a function called build person.  It will not have any input parameters, but it will return an object that represents a person.

Inside this function, use individual prompt statements to ask the user for the family member’s: full name, age, relationship (to you), favorite color, and favorite food.  For example: Joe Smith, 79, grandpa, brown, prunes.  Collect these bits of data in local variables inside the function. Example: var fullName = prompt("What is their full name?");

Once you have variables that contain each of these items, create a new object that contains these values and add them to the object.  Then, return the object from the function.

Explanation / Answer

package chegg;

import java.util.Scanner;

public class build_person {
  
  
   String name , relation , color ,food;
   int age;
   build_person bp;
   build_person buildperson(){
      
       return bp;
   }
  
   public build_person( String name , String relation , String color , String food, int age){
       this.age= age;
       this.name= name;
       this.color= color;
       this.relation= relation;
       this.food= food;
   }
  
   public static void main(String[] args) {
      
       Scanner sc = new Scanner(System.in);
       System.out.println("full name");
       String name = sc.next();
       System.out.println("age");
       int age = sc.nextInt();
       System.out.println("Relationship to you");
       String relation = sc.next();
       System.out.println("favourite color");
       String color = sc.next();
       System.out.println("favourite food");
       String food = sc.next();
      
       build_person bp = new build_person(name , relation, color, food , age);
      
       bp.buildperson();
      
      
      
   }
  
  
  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote