Question

I need help in converting this into pseudo-code Student.java public class Student implements Comparable<Student>{ private String...

I need help in converting this into pseudo-code

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Don't panic for psudocode,it is nothing but a piece of code easily understood by humans. So if you want to convert it to psudocode just remove the java java related keywords and keep the simple logic code. For example

Class Student

DECLARE name, major, status

Add a comment
Know the answer?
Add Answer to:
I need help in converting this into pseudo-code Student.java public class Student implements Comparable<Student>{ private String...
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
  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and sh...

    java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...

  • This is my playlist class: class Playlist{       private String name;    private int numberOfRecordings...

    This is my playlist class: class Playlist{       private String name;    private int numberOfRecordings = 0;    private int durationInSeconds = 0;    private int MAX_PLAYLIST_SIZE;    Recording recordingslist[];       Playlist(){        name = "Unknown";        MAX_PLAYLIST_SIZE = 5;        recordingslist = new Recording[MAX_PLAYLIST_SIZE];        durationInSeconds = 0;    }       Playlist(String name, int size){        this.name = name;        this.MAX_PLAYLIST_SIZE = size;        recordingslist = new Recording[MAX_PLAYLIST_SIZE];   ...

  • public class Scheduler {    private List<Course> classes;    private List<Student> students;    public Scheduler() {...

    public class Scheduler {    private List<Course> classes;    private List<Student> students;    public Scheduler() {        classes = new ArrayList<Course>();        students = new ArrayList<Student>();    }       public void addCourse(Course course) {        this.classes.add(course);    }    public List<Course> getCourses() {        List<Course> newCList=new ArrayList<>();        for(int i=0;i<classes.size();i++){        newCList.add(classes.get(i));        }        return newCList;    }    public void addStudent(Student student) {        this.students.add(student);    }   ...

  • 4. Command pattern //class Stock public class Stock { private String name; private double price; public...

    4. Command pattern //class Stock public class Stock { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public void buy(int quantity){ System.out.println(“BOUGHT: “ + quantity + “x “ + this); } public void sell(int quantity){ System.out.println(“SOLD: “ + quantity + “x “ + this); } public String toString() { return “Product [name=” + name + “, price=” + price + “]”; } } a. Create two command classes that...

  • I need a shoppingcartmanager.java that contains a main method for this code in java Itemtopurchase.java public...

    I need a shoppingcartmanager.java that contains a main method for this code in java Itemtopurchase.java public class ItemToPurchase {    // instance variables    private String itemName;    private String itemDescription;    private int itemPrice;    private int itemQuantity;    // default constructor    public ItemToPurchase() {        this.itemName = "none";        this.itemDescription = "none";        this.itemPrice = 0;        this.itemQuantity = 0;    }    public ItemToPurchase(String itemName, int itemPrice, int itemQuantity,String itemDescription) {   ...

  • class Upper { private int i; private String name; public Upper(int i){ name = "Upper"; this.i...

    class Upper { private int i; private String name; public Upper(int i){ name = "Upper"; this.i = i;} public void set(Upper n){ i = n.show();} public int show(){return i;} } class Middle extends Upper { private int j; private String name; public Middle(int i){ super(i+1); name = "Middle"; this.j = i;} public void set(Upper n){ j = n.show();} public int show(){return j;} } class Lower extends Middle { private int i; private String name; public Lower(int i){ super(i+1); name =...

  • Java Do 68a, 68b, 68c, 68d. Show code & output. public class Employee { private int...

    Java Do 68a, 68b, 68c, 68d. Show code & output. public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...

  • A teacher wants to create a list of students in her class. Using the existing Student...

    A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static ArrayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList. Coding below was given to edit and use public class ClassListTester { public static void main(String[] args) { //You don't need to change anything here, but feel free...

  • A teacher wants to create a list of students in her class. Using the existing Student...

    A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static ArrayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList. Coding below was given to edit and use public class ClassListTester { public static void main(String[] args) { //You don't need to change anything here, but feel free...

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