Debugging exercise
Programmer Began programming the following program, but made some mistakes.
Please debug:
class Student{
private int id;
private String name;
private String city;
Student(String name, String city){
this.name = name;
this.city = city;
}
Student(int id, String place){
this.id = id;
this.place =name;
}
void Student(int id, String name, String city){
this.id = id;
this.name = name;
this.city = city;
}
protected void print(){
If (city.equals(null))
{
System.out.println(id + “ “ + name);
}
Else if (id == 0)
{
System.out.println(id " " + name +
" " + city);
}
Else if
}
Programmer Began programming the following program, but made some mistakes.
Please debug.
public class ThisDemo {
public static void main(String[] args) {
Student malestudent = new Student(111,"John");
Student femalestudent = new Student(321,Mary, "Oakland");
Student noID = new Student("Steve","Orinda");
maleStudent.print();
femaleStudent.print();
noID.print();
}
}
in Java
class Student {
private int id;
private String name;
private String city;
Student(String name, String city) {
this.name = name;
this.city = city;
}
Student(int id, String place) {
this.id = id;
this.name = place;
}
Student(int id, String name, String city) {
this.id = id;
this.name = name;
this.city = city;
}
protected void print() {
if (city == null)
{
System.out.println(id + " " + name);
}
else if (id == 0)
{
System.out.println( name +
" " + city);
}else {
System.out.println( id +
" " + city);
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------------
public class ThisDemo {
public static void main(String[] args) {
Student malestudent = new Student(111,"John");
Student femalestudent = new Student(321, "MaryOakland");
Student noID = new Student("Steve","Orinda");
malestudent.print();
femalestudent.print();
noID.print();
}
}
------------------------------------------------------------------------------------------------------------------------------------------
See Output

Thanks, PLEASE COMMENT if there is any concern.
Debugging exercise Programmer Began programming the following program, but made some mistakes. Please debug: class Student{...
FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...
In this exercise, we will be refactoring a working program. Code refactoring is a process to improve an existing code in term of its internal structure without changing its external behavior. In this particular example, we have three classes Course, Student, Instructor in addition to Main. All classes are well documented. Read through them to understand their structure. In brief, Course models a course that has a title, max capacity an instructor and students. Instructor models a course instructor who...
Java
Do 72a, 72b, 72c, 72d. Code & output required.
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;...
I need help displaying two zeroes in hours:minutes:seconds. In
Java.
I need some help for the time to display correctly. I want it to
display double zeroes. 06:00:00 and 12:00:00.
public class Clock {
String name;
static int uid=100;
int id;
int hr;
int min;
int sec;
public Clock() {
this.name="Default";
this.id=uid;
this.hr=00;
this.min=00;
this.sec=00;
uid++;
}
public Clock(String name, int hr, int min, int sec) {
if (hr<=24 && min <=60 && sec <=60)
{
this.hr = hr;
this.min...
I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student { private String firstName; private String lastName; private String id; private boolean tuitionPaid; public Student(String firstName, String lastName, String id, boolean tuitionPaid) { this.firstName=firstName; this.lastName=lastName; this.id=id; this.tuitionPaid=tuitionPaid; } ...
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...
Java Programming
Answer 60a, 60b, 60c, 60d. 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...
Modify the objectstudent JAVA program to add a private variable zipcode, you must also add setters and getter methods for the new variable and modify the toString method. The objectstudent program is in this weeks module, you can give it a default value of 19090. class Student { private int id; private String name; public Student() { id = 8; name = "John"; } public int getid() { return id; } public String getname() { return name; } public void...
I need help converting the following two classes into one sql table package Practice.model; import java.util.ArrayList; import java.util.List; import Practice.model.Comment; public class Students { private Integer id; private String name; private String specialties; private String presentation; List<Comment> comment; public Students() {} public Students(Integer id,String name, String specialties, String presentation) { this.id= id; this.name = name; this.specialties = specialties; this.presentation = presentation; this.comment = new ArrayList<Commment>(); } public Students(Integer id,String name, String specialties, String presentation, List<Comment> comment) { this.id= id; this.name...
Implement the following in java. 1. An insertAtBeginning(Node newNode) function, that inserts a node at the beginning(root) of the linked list. 2. A removeFromBeginning() function, that removes the node from the beginning of the linked list and assigns the next element as the new beginning(root). 3. A traverse function, that iterates the list and prints the elements in the linked list. For the insertAtBeginning(Node newNode) function: 1. Check if the root is null. If it is, just assign the new...