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

Fill In the Gap [Q.1] Answer the following questions We want to write a simple a

ID: 3577396 • Letter: F

Question

Fill In the Gap

[Q.1] Answer the following questions

We want to write a simple application for creating student data and retrieve them based on JSF framework. Student data are stored in HashMap.

lookupStudentData.xhtml   //renders a user interface to query a student record


There are three valid student IDs: 001, 002, 003 (in String type).

When user clicks “Get Student Data button, student data is retrieved from the HashMap and shown to the user by showStudentData.xhtml as follows.

If studentID is invalid unknownStudent.xhtml will display the following page.

For implementing this application, we need StudentLookupAPI.java and StudentData.java to store student data.

StudentLookupAPI.java

public interface StudentLookupAPI {

public Student findStudent(String id);

}

StudentData.java

import java.util.HashMap;

import java.util.Map;

public class StudentData

   implements StudentLookupAPI {

private Map<String,Student> students;

public StudentData() {

students = new HashMap<String,Student>();

addStudent(new Student("001", "Bob Feiner", 3.2));

addStudent(new Student("002", "Linda Brown", 3.5));

addStudent(new Student("003", "Bill Clinton", 2.9));

}

/** Finds the student with the given ID.

   * Returns null if there is no match. */

  

public Student findStudent(String id) {

if (id != null) {

return students.get(id);

} else {

return null;

}

}

private void addStudent(Student student) {//helper method

students.put(student.getId(), student);

}

}

(1)   Complete Student.java bean based on the following code skeleton (Note we do not need set methods). Fill out blank lines and box.

public class Student {

private String id, name;

private double GPA;

public Student(String id, String name, double GPA) {//constructor

  

}

public String ____________ {//accessor

return id;

}

public String _____________{//accessor

return name;

}

public double _____________{//accessor

return GPA;

}

}

StudentBean.java and StudentBean2.java are managed beans for searching student record from the HashMap.

(2)   Complete StudentBean.java based on the following code skeleton. Fill out the blank lines

@Named

@SessionScoped

public class StudentBean implements Serializable {

protected String studentId;

protected Student student;

private static StudentLookupAPI lookupAPI =

new StudentData();

public String _________________ {//accessor

return studentId;

}

public void setStudentId(String studentId) {

this.studentId = studentId.trim();

if (this.studentId.isEmpty()) {

this.studentId = "none entered";

}

}

public Student _______________ {//accessor

return student;

}

public String getStudentData { //action control method

student = lookupAPI._______________(studentId); //get student object whose id is studentId

if (student == null) {

return ____________________

} else {

return _______________________

}

}

}

Studentbean2.java

@Named

@SessionScoped

public class StudentBean2 extends StudentBean implements Serializable {

@Override

public String getStudentData() {

String jsfPage = super.getStudentData();

return(jsfPage + "?faces-redirect=true"); //if faces-redirect=true, you can show the target

//xhtml on the URL window of the browser

}

}

(3)   Complete studentLookup.xhtml based on the following code skeleton. Fill out blank lines.

<h:body>

<h1>Lookup Student Data</h1>

<h:form>

Student ID:

<h:inputText value="#{studentBean2._____________}"/><br/>

<h:commandButton value="Get Student Data"

   action="#{studentBean2.______________}"/>

</h:form>

</h:body>

(4)   Complete showStudentData.xhtml based on the following code skeleton. Fill out blank lines.

<h:body>

<h1>Selected Student Data</h1>

<ul>

<li>Student ID: ____________________________</li>

<li>Student Name: __________________________</li>

<li>Student GPA: ____________________________</li>

</ul>

</h:body>

(5)   Complete unknowStudent.xhtml based on the following code skeleton. Fill out blank lines.

<h:body>

<h1>Unknown Student</h1>

   <h2>No student found with id ____________________________</h2>

<p><h:link __________=_______________ value="Please try again"/></p>

</h:body>

The hyperlink redirects to studentLookup.xhtml.

Explanation / Answer

void metric linear unit (int c[][], int a[][], int b[][])

Here's my million instructions per second code:

.text
main:
j mm

mm:
la $a3, array_A # base address for array_A loaded into $a3
la $a1, array_B # base address for array_B loaded into $a1
la $a2, array_C # base address for array_C loaded into $a2

li $t1, four # $t1 = four (row-size and loop end)
li $s0, zero # i = 0; initialize first for loop
loop1:
li $s1, zero # j = 0; restart second for loop
loop2:
li $s2, zero # k = 0; restart third for loop
sll $t2, $s0, a pair of # $t2 = i * four (size of row of c)
addu $t2, $t2, $s1 # $t2 = i * size(row) + j
sll $t2, $t2, a pair of # $t2 = computer memory unit offset of [i][j]
addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j]
lw $t4, 0($t2) # $t4 = a pair of bytes of c[i][j]
loop3:
sll $t0, $s2, a pair of # $t0 = k * four (size of row of b)
addu $t0, $t0, $s1 # $t0 = k * size(row) + j
sll $t0, $t0, a pair of # $t0 = computer memory unit offset off [k][j]
addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j]
lw $t5, 0($t0) # $t5 = a pair of bytes of b[k][j]
sll $t0, $s0, a pair of # $t0 = i * four (size of row of a)
addu $t0, $t0, $s2 # $t0 = i * size(row) + k
sll $t0, $t0, a pair of # $t0 = computer memory unit offset of [i][k]
addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k]
lw $t6, 0($t0) # $t6 = a pair of bytes of a[i][k]
mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j]
add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]
addiu $s2, $s2, one # $k = k + one
bne $s2, $t1, loop3 #if (k != 4) visit loop3
sw $t4, 0($a2) # c[i][j] = $t4
#----------TEST-------------
li $v0, 1

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