1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
laila [671]
3 years ago
5

Create a class named Person that holds the following fields: two String objects for the person’s first and last name and a Local

Date object for the person’s birthdate. Create a class named Couple that contains two Person objects. Create a class named Wedding for a wedding planner that includes the date of the wedding, the Couple being married, and a String for the location.

Computers and Technology
2 answers:
faust18 [17]3 years ago
7 0

Answer:

Check the explanation

Explanation:

I have added comments in the code for your easy reference.

//Code for this solution

//File: Person.java

import java.time.LocalDate;

//Person class

public class Person {

//Member variables

private String firstName;

private String lastName;

private LocalDate birthDate;

//Paramterized constructors that initializes all the member variables

public Person(String fName, String lName, LocalDate bDate) {

firstName = fName;

lastName = lName;

birthDate = bDate;

}

//Getter methods for each of the member variables

public String getFirstName() {

return firstName;

}

public String getLastName() {

return lastName;

}

public LocalDate getBirthDate() {

return birthDate;

}

}

//File: Couple.java

//Couple class

public class Couple {

//Member variables

private Person person1;

private Person person2;

//Paramterized constructors that initializes all the member variables

public Couple(Person p1, Person p2) {

person1 = p1;

person2 = p2;

}

//Getter methods for each of the member variables

public Person getFirstPerson() {

return person1;

}

public Person getSecondPerson() {

return person2;

}

}

 

//File: Wedding.java

import java.util.Date;

//Wedding class

public class Wedding {

//Member variables

private Date weddingDate;

private Couple couple;

private String location;

//Paramterized constructors that initializes all the member variables

public Wedding(Date date, Couple c, String wedLocation) {

weddingDate = date;

couple = c;

location = wedLocation;

}

//Getter methods for each of the member variables

public Date getWeddingDate() {

return weddingDate;

}

public Couple getCouple() {

return couple;

}

public String getLocation() {

return location;

}

}

//File: TestWedding.java

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.time.LocalDate;

import java.time.format.DateTimeFormatter;

//Test driver class

public class TestWedding {

private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

//Method to display Wedding details - Couple, Location and Wedding date

public static void displayWedding(Wedding w) {

System.out.println("");

System.out.println("=== Wedding details ===");

Person p1 = w.getCouple().getFirstPerson();

Person p2 = w.getCouple().getSecondPerson();

System.out.println(p1.getFirstName() + " " + p2.getLastName() + "(born " + p1.getBirthDate().format(DateTimeFormatter.ISO_DATE) + ")"

+ " weds " + p2.getFirstName() + " " + p2.getLastName() + "(born " + p2.getBirthDate().format(DateTimeFormatter.ISO_DATE) + ")");

System.out.println("ON");

System.out.println( simpleDateFormat.format( w.getWeddingDate()));

System.out.println("AT");

System.out.println(w.getLocation());

}

//Test method - to create Person, Couple and Wedding objects

public static void main(String[] args) throws ParseException {

//Create Person objects

Person p10 = new Person("John", "Howard", LocalDate.of(2000, 10, 1));

Person p11 = new Person("Mary", "Eliza", LocalDate.of(2002, 1, 2));

//Create Couple object with above data

Couple c1 = new Couple(p10, p11);

//Create Wedding Object

Wedding w1 = new Wedding( simpleDateFormat.parse("2019-05-06"), c1, "CountrySide");

//Display Wedding details

displayWedding(w1);

Person p20 = new Person("James", "Howler", LocalDate.of(1999, 5, 1));

Person p21 = new Person("Jenny", "Hertz", LocalDate.of(2005, 4, 25));

Couple c2 = new Couple(p20, p21);

Wedding w2 = new Wedding(simpleDateFormat.parse("2019-10-02"), c2, "Mary Islands");

displayWedding(w2);

}

}

Kindly check the attached image below for the code output.

BabaBlast [244]3 years ago
5 0

Answer:

See explaination

Explanation:

// Person.java

import java.time.LocalDate;

public class Person {

//attributes

private String firstName;

private String lastName;

private LocalDate birthDate;

//constructor initializing all fields

public Person(String firstName, String lastName, LocalDate birthDate) {

this.firstName = firstName;

this.lastName = lastName;

this.birthDate = birthDate;

}

//getter methods

public String getFirstName() {

return firstName;

}

public String getLastName() {

return lastName;

}

public LocalDate getBirthDate() {

return birthDate;

}

//returns a String containing first and last names

public String toString() {

return firstName + " " + lastName;

}

}

// Couple.java

public class Couple {

//Persons getting married

private Person person1;

private Person person2;

//constructor

public Couple(Person person1, Person person2) {

this.person1 = person1;

this.person2 = person2;

}

//getters

public Person getPerson1() {

return person1;

}

public Person getPerson2() {

return person2;

}

}

// Wedding.java

import java.time.LocalDate;

public class Wedding {

//date of wedding

private LocalDate weddingDate;

//Couple getting married

private Couple couple;

//constructor

public Wedding(LocalDate weddingDate, Couple couple) {

this.weddingDate = weddingDate;

this.couple = couple;

}

//getters

public LocalDate getWeddingDate() {

return weddingDate;

}

public Couple getCouple() {

return couple;

}

atOverride

public String toString() {

return couple.getPerson1()+" weds "+couple.getPerson2();

}

}

// TestWedding.java

import java.time.LocalDate;

import java.time.format.DateTimeFormatter;

public class TestWedding {

//method to display details about a wedding

public static void display(Wedding wedding) {

System.out.println("***Wedding***");

System.out.println("Person 1: " + wedding.getCouple().getPerson1());

System.out.println("Person 2: " + wedding.getCouple().getPerson2());

System.out.println("Date: " + wedding.getWeddingDate().format(DateTimeFormatter.ofPattern("dd/MMM/yyyy")));

}

public static void main(String[] args) {

//a DateTimeFormatter object for parsing date from String

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");

//creating Couple 1

Couple c1 = new Couple(new Person("Oliver", "Queen", LocalDate.parse("11/01/1994",formatter)),

new Person("Felicity", "Smoak", LocalDate.parse("10/07/1996",formatter)));

//creating a Wedding

Wedding wedding1=new Wedding(LocalDate.parse("01/09/2019",formatter), c1);

//creating another couple and wedding

Couple c2 = new Couple(new Person("John", "Diggle", LocalDate.parse("01/08/1989",formatter)),

new Person("Lyla", "Michaels", LocalDate.parse("03/07/1990",formatter)));

Wedding wedding2=new Wedding(LocalDate.parse("08/09/2019",formatter), c2);

//displaying both

display(wedding1);

display(wedding2);

}

}

You might be interested in
A10:A20 Refer to values in
Keith_Richards [23]
The range of cells in column A and rows 10 through 20
8 0
2 years ago
Given a string, an integer position, and an integer length, all on separate lines, output the substring from that position of th
lana [24]

quetma es elpx mjeghgieo

4 0
3 years ago
Write the class "Tests". Ensure that it stores a student’s first name, last name, all five test scores, the average of those 5 t
zhannawk [14.2K]

Answer:

The following assumption will be made for this assignment;

  • If average score is greater than 75, the letter grade is A
  • If average score is between 66 and 75, the letter grade is B
  • If average score is between 56 and 65, the letter grade is C
  • If average score is between 46 and 55, the letter grade is D
  • If average score is between 40 and 45, the letter grade is E
  • If average score is lesser than 40, the letter grade is F

The program is written in Java and it uses comments to explain difficult lines. The program is as follows

import java.util.*;

public class Tests

{

public static void main(String [] args)

{

 //Declare variables

 Scanner input = new Scanner(System.in);

 String firstname, lastname;

 //Prompt user for name

 System.out.print("Enter Lastname: ");

 lastname = input.next();

 System.out.print("Enter Firstname: ");

 firstname = input.next();

 char grade;

 //Declare Array

 int[] Scores = new int[5];

 //Initialize total scores to 0

 int total = 0;  

  //Decalare Average

  double   average;

 //Prompt user for scores

 for(int i =0;i<5;i++)

 {

  System.out.print("Enter Score "+(i+1)+": ");

  Scores[i] = input.nextInt();

  //Calculate Total Scores

  total+=Scores[i];

 }

 //Calculate Average

 average = total/5.0;

 //Get Letter Grade

 if(average>75)

 {

 grade = 'A';

 }

 else if(average>65)

 {

 grade = 'B';

 }

 else if(average>55)

 {

 grade = 'C';

 }

 else if(average>45)

 {

 grade = 'D';

 }

 else if(average>40)

 {

 grade = 'E';

 }

 else

 {

 grade = 'F';

 }

 //Print Student Results

 System.out.print("Fullname: "+lastname+", "+firstname);

 System.out.print('\n');

 System.out.print("Total Scores: "+total);

 System.out.print('\n');

 System.out.print("Average Scores: "+average);

 System.out.print('\n');

 System.out.print("Grade: "+grade);

}

}

See Attachment for .java file

Download java
7 0
3 years ago
You are tasked to calculate a specific algebraic expansion, i.e. compute the value of f and g for the expression: ???? = (??????
melisa1 [442]

Answer:

.data

prompt: .asciiz "Enter 4 integers for A, B, C, D respectively:\n"

newLine: .asciiz "\n"

decimal: .asciiz "f_ten = "

binary: .asciiz "f_two = "

decimal2: .asciiz "g_ten = "

binary2: .asciiz "g_two = "

.text

main:

#display prompt

li $v0, 4

la $a0, prompt

syscall

#Read A input in $v0 and store it in $t0

li $v0, 5

syscall

move $t0, $v0

#Read B input in $v0 and store it in $t1

li $v0, 5

syscall

move $t1, $v0

#Read C input in $v0 and store it in $t2

li $v0, 5

syscall

move $t2, $v0

#Read D input in $v0 and store it in $t3

li $v0, 5

syscall

move $t3, $v0

#Finding A^4

#Loop (AxA)

li $t6, 0

L1:

bge $t6, $t0, quit

add $s1, $s1, $t0 # A=S+A => $s1= A^2

addi $t6, $t6, 1 # i=i+1

j L1

quit:

#Loop (A^2 x A^2)

li $t6, 0

L1A:

bge $t6, $s1, quit1A

add $s5, $s5, $s1

addi $t6,$t6, 1

j L1A

#End of Finding A^4

#Finding 4xA^3

quit1A:

#Loop (4xB)

li $t6, 0

L2:

bge $t6, 4, quit2

add $s2, $s2, $t1

addi $t6, $t6, 1

j L2

quit2:

#Loop (BxB)

li $t6 , 0

L2A:

bge $t6, $t1, quit2A #loop2

add $s6, $s6, $t1 #add

addi $t6, $t6, 1 #add immediate

j L2A #loop2

quit2A: # perform proper program termination using syscall for exit

#Loop (BxB)

li $t6 , 0 #load immediate

L2AA:

bge $t6, $s2, quit2AA #loop2

add $t7, $t7, $s6 #add

addi $t6, $t6, 1 #add immediate

j L2AA #loop2

#End ofFinding 4xA^3

#Finding 3xC^2

quit2AA: # perform proper program termination using syscall for exit

#3 Loop (3 x (C x C)) FOR S3

li $t6 , 0 #load immediate

L3:

bge $t6, $t2, quit3 #loop3

add $s3, $s3, $t2 #add

addi $t6,$t6, 1 #add immediate

j L3 #loop3

quit3: # perform proper program termination using syscall for exit

#3 Loop (3 x (C x C)) FOR S3

li $t6 , 0 #load immediate

L3A:

bge $t6, 3, quit3A #loop3

add $s0, $s0, $s3 #add

addi $t6,$t6, 1 #add immediate

j L3A #loop3

#End of Finding 3xC^2

#Finding 2xD

quit3A: # perform proper program termination using syscall for exit

#4 Loop (2 x D) FOR S4

li $t6 , 0

L4:

bge $t6, 2, quit4 #loop4

add $s4, $s4, $t3 #add

addi $t6, $t6, 1 #add immediate

j L4 #Loop4

#End of Finding 2xD

#Finding AxB^2

quit4:

li $t6, 0

li $s1, 0

L5:

bge $t6, $t1, quit5

add $s1, $s1, $t1

addi $t6, $t6, 1

j L5

quit5:

li $t6, 0

li $s2, 0

L6:

bge $t6, $t0, quit6

add $s2, $s2, $s1

addi $t6, $t6, 1

j L6

#End of Finding AxB^2

#Finding C^2XD^3

quit6: #finds C^2

li $t6, 0

li $s1, 0

L7:

bge $t6, $t2, quit7

add $s1, $s1, $t2

addi $t6, $t6, 1

j L7

quit7: #finds D^2

li $t6, 0

li $s6, 0

L8:

bge $t6, $t3, quit8

add $s6, $s6, $t3

addi $t6, $t6, 1

j L8

quit8: #finds D^3

li $t6, 0

li $s7, 0

L9:

bge $t6, $t3, quit9

add $s7, $s7, $s6

addi $t6, $t6, 1

j L9

quit9: #finds C^2XD^3

li $t6, 0

li $s3, 0

L10:

bge $t6, $s1, end

add $s3, $s3, $s7

addi $t6, $t6, 1

j L10

#End of Finding C^2XD^3

end: # perform proper program termination using syscall for exit

#f is $t8

li $t8 , 0

sub $t8, $s5, $t7 # addition

add $t8, $t8, $s0 # subract

sub $t8,$t8, $s4 # subract

#g is $t9

li $t9 , 0

add $t9, $s2, $s3 # addition

#Display

#1st equation

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, decimal # Gives answer in decimal value

syscall # value entered is returned in register $v0

li $v0, 1 # display the answer string with syscall having $v0=1

move $a0, $t8 # moves the value from $a0 into $t8

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, binary # Gives answer in binary

syscall # value entered is returned in register $v0

li $v0, 35

move $a0, $t8 # moves the value from into $a0 from $t8

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

#2nd equation

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, decimal2 # Gives answer in decimal value

syscall # value entered is returned in register $v0

li $v0, 1 # display the answer string with syscall having $v0=1

move $a0, $t9 # moves the value from $a0 into $t8

syscall # value entered is returned in reg $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, binary2 # Gives answer in binary

syscall # value entered is returned in register $v0

li $v0, 35

move $a0, $t9 # moves the value from into $a0 from $t8

syscall # value entered is returned in register $v0

li $v0,4 # display the answer string with syscall having $v0=4

la $a0, newLine # puts newLine in between answers

syscall # value entered is returned in register $v0

#end the program

li $v0, 10

syscall

8 0
2 years ago
Which statement is true?
qaws [65]

Answer:

An employee list can give the departments and job titles of employees.

Explanation:

Well you have to your employees age birth certificate  and stuff like that on file and there department and title would bee in that file.

4 0
2 years ago
Read 2 more answers
Other questions:
  • A file that contains program code is called a ____________.
    13·1 answer
  • Computer a sends a packet intended to reach computer f. along its path it arrives at computer
    15·1 answer
  • If you are driving at night, you should not use high-beam headlights within _________ of oncoming vehicles. Florida Road Rules 4
    9·2 answers
  • Why is Apple using social media ?
    15·1 answer
  • What is meant by the term drill down?
    10·1 answer
  • Describe how spacecraft evolved from the US Mercury to contemporary space shuttles.
    10·1 answer
  • What is the meaning of the term plot?<br>A. the final outcome of the story​
    8·1 answer
  • Identify 5 products/services needed by the people in our current situation.<br>​
    6·1 answer
  • Reading (BCK FORM 2C IT 2020-2021)
    12·2 answers
  • According to Okun's law, if the unemployment rate goes from 7% to 4%, what
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!