Question

Data Structures Java 1. Develop an algorithm for evaluating desirable qualities in individuals. Your algorithm should...

Data Structures Java

1. Develop an algorithm for evaluating desirable qualities in individuals. Your algorithm should look for specific features and accept a ranking on each criterion for each person evaluated. It should evaluate individuals until the user quits. [22 points]

For the desirable qualities of the individuals I used basic criteria of their Academic Major,Are the doing Average , Good or Excellent ,  if it helps :)

Ex. Name : John

Major : Computer science

Status: Excellent

Name: James

Major : Safety

Status : Good.

Ranking: John then James since he is doing better Academically .


thats all the information I was provided with thats why I needed help
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Student.java

public class Student implements Comparable<Student>{
private String name, major, status;
private int rank;
  
public Student()
{
this.name = this.major = this.status = "";
this.rank = 0;
}
  
public Student(String name, String major, String status)
{
this.name = name;
this.major = major;
this.status = status;
}

public String getName() {
return name;
}

public String getMajor() {
return major;
}

public String getStatus() {
return status;
}
  
public int getRank()
{
return this.rank;
}
  
public void setRank(int rank)
{
this.rank = rank;
}
  
@Override
public String toString()
{
return("Name: " + this.name + ", Major: " + this.major + ", Status: " + this.status);
}

@Override
public int compareTo(Student o) {
if(this.rank < o.getRank())
return -1;
else if(this.rank == o.getRank())
return 0;
else
return 1;
}
}

RankIndividuals.java

import java.util.ArrayList;
import java.util.Collections;

public class RankIndividuals {
private ArrayList<Student> students;
private ArrayList<Integer> ranks;
  
public RankIndividuals()
{
this.students = new ArrayList<>();
this.ranks = new ArrayList<>();
}
  
public void addStudents(Student student)
{
this.students.add(student);
}
  
public void giveRank()
{
for(int i = 0; i < students.size(); i++)
{
if(students.get(i).getStatus().equalsIgnoreCase("Excellent"))
students.get(i).setRank(1);
if(students.get(i).getStatus().equalsIgnoreCase("Very Good"))
students.get(i).setRank(2);
if(students.get(i).getStatus().equalsIgnoreCase("Good"))
students.get(i).setRank(3);
if(students.get(i).getStatus().equalsIgnoreCase("Average"))
students.get(i).setRank(4);
if(students.get(i).getStatus().equalsIgnoreCase("Bad"))
students.get(i).setRank(5);
}
Collections.sort(this.students);
}
  
public void displayAllStudents()
{
for(Student st : this.students)
{
System.out.println(st);
}
}
}

RankerApp.java (Main class)

public class RankerApp {
  
public static void main(String[] args)
{
RankIndividuals individuals = new RankIndividuals();
individuals.addStudents(new Student("John", "Computer Science", "Good"));
individuals.addStudents(new Student("Alice", "Geography", "Excellent"));
individuals.addStudents(new Student("Henry", "Physics", "Average"));
individuals.addStudents(new Student("Maxx", "English", "Bad"));
individuals.addStudents(new Student("Joseph", "Chemistry", "Average"));
individuals.addStudents(new Student("Nuke", "Mathematics", "Very Good"));
  
System.out.println("STUDENTS BEFORE RANKING:\n------------------------");
individuals.displayAllStudents();
  
individuals.giveRank();
  
System.out.println("\nSTUDENTS AFTER RANKING:\n-----------------------");
individuals.displayAllStudents();
}
}

******************************************************************* SCREENSHOT ********************************************************

Add a comment
Answer #2

To develop an algorithm for evaluating desirable qualities in individuals based on specific features and rankings, you can follow these steps:

  1. Initialize an empty list or data structure to store the evaluated individuals and their rankings.

  2. Start a loop to continuously evaluate individuals until the user chooses to quit.

  3. Prompt the user to enter the individual's name, major, and academic status.

  4. Store the entered information in variables.

  5. Calculate the ranking based on the given criteria (in this case, the academic status). You can assign weights or points to each level of the academic status (e.g., Average: 1 point, Good: 2 points, Excellent: 3 points).

  6. Create a data structure (e.g., a dictionary or an object) to hold the individual's name, major, academic status, and ranking.

  7. Add the data structure to the list of evaluated individuals.

  8. Repeat the loop for evaluating additional individuals or provide an option for the user to quit.

  9. Once the user chooses to quit, sort the list of evaluated individuals based on their rankings in descending order.

  10. Display the evaluated individuals in the sorted order, showing the name, major, academic status, and ranking.

Here's a Python-like pseudocode representation of the algorithm:

pythonCopy codeindividuals = []while True:
    name = input("Enter the individual's name (or 'quit' to exit): ")    if name == 'quit':        break
    
    major = input("Enter the individual's major: ")
    status = input("Enter the individual's academic status (Average, Good, Excellent): ")
    
    ranking = 0
    if status == 'Average':
        ranking = 1
    elif status == 'Good':
        ranking = 2
    elif status == 'Excellent':
        ranking = 3
    
    individual = {        'name': name,        'major': major,        'status': status,        'ranking': ranking
    }
    
    individuals.append(individual)

individuals.sort(key=lambda x: x['ranking'], reverse=True)print("\nEvaluated individuals:")for individual in individuals:    print(f"Name: {individual['name']}")    print(f"Major: {individual['major']}")    print(f"Academic Status: {individual['status']}")    print(f"Ranking: {individual['ranking']}")    print()

This algorithm allows you to evaluate individuals based on their desirable qualities, in this case, their academic status, and rank them accordingly. The evaluated individuals are sorted based on their rankings to provide a clear picture of their standings.

answered by: Hydra Master
Add a comment
Know the answer?
Add Answer to:
Data Structures Java 1. Develop an algorithm for evaluating desirable qualities in individuals. Your algorithm should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ________ individuals attempt to control situations, including the thoughts and actions of others. Question 1 options:...

    ________ individuals attempt to control situations, including the thoughts and actions of others. Question 1 options: A) Analytical B) Responsive C) Versatile D) Expressive E) Assertive Save Question 2 (1 point) Ken likes to see the big picture when salespeople present to him. He finds it enjoyable to know a little about them and their families. He takes his work very seriously, and the company's overall success, as well as his own personal success, are very important to him. Ken...

  • Hello! Could you please write your own four paragraph (5-6 sentences per paragraph) take away or...

    Hello! Could you please write your own four paragraph (5-6 sentences per paragraph) take away or reflection of the below information? Please complete in 24 hours if possible. Thank you! RIS BOHNET THINKS firms are wasting their money on diversity training. The problem is, most programs just don’t work. Rather than run more workshops or try to eradicate the biases that cause discrimination, she says, companies need to redesign their processes to prevent biased choices in the first place. Bohnet...

  • Hi there! I need to compare two essay into 1 essay, and make it interesting and...

    Hi there! I need to compare two essay into 1 essay, and make it interesting and choose couple topics which im going to talk about in my essay FIRST ESSAY “Teaching New Worlds/New Words” bell hooks Like desire, language disrupts, refuses to be contained within boundaries. It speaks itself against our will, in words and thoughts that intrude, even violate the most private spaces of mind and body. It was in my first year of college that I read Adrienne...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT