Question

In: Computer Science

Complete the attached program by adding the following: a) add the Java codes to complete the...

Complete the attached program by adding the following:

a) add the Java codes to complete the constructors for Student class

b) add the Java code to complete the findClassification() method

c) create an object of Student and print out its info in main() method of StudentInfo class.

 *
 * @author 
 * @CS206  HM#2
 * @Description:
 *
 */
public class StudentInfo {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        //Create an object of Student 
        
        //Print out this object's info: myName, myAge,myGender,
        //and classification
        
    }
    
}
class Student{
  String myName; 
  int myAge; 
  char myGender; 
  int myCreditsEarned; 
  
  Student() 
  //no-arg constructor
  //assigns initial values to the data membmers in Student
         
  {
      
  }
  Student(String name, int age, char gender, int credits)
  //parameterized constructor
  //uses the paramters to assign initial values to 
  //the data members in Student   
  {
      
  }
  String findClassification()
  // use myCreditsEarned to determine the student's classification
  // if myCreditsEarned>=90, return "Senior";
  // if 60<=myCreditsEarned<90, return "Junior";
  // if 30<=myCreditsEarned<60, return "Sophomore";
  // if myCreditsEarned<30, return "Freshman".             
  {
      
      
  }
}

Solutions

Expert Solution

public class StudentInfo {

        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
                // TODO code application logic here
                // Create an object of Student

                // Print out this object's info: myName, myAge,myGender,
                // and classification
                //created student object
                Student s = new Student("Uday", 25, 'M', 99);
                // printing the data
                System.out.println("Name: " + s.myName);
                System.out.println("Age: " + s.myAge);
                System.out.println("Gender: " + s.myGender);
                System.out.println("Classification: " + s.findClassification());
        }

}

class Student {
        String myName;
        int myAge;
        char myGender;
        int myCreditsEarned;

        Student()
        // no-arg constructor
        // assigns initial values to the data membmers in Student

        {
                myAge = 0;
                myCreditsEarned = 0;
                myName = "";
                myGender = ' ';
        }

        Student(String name, int age, char gender, int credits)
        // parameterized constructor
        // uses the paramters to assign initial values to
        // the data members in Student
        {
                // assignign the data to the instance variables
                myName = name;
                myAge = age;
                myGender = gender;
                myCreditsEarned = credits;
        }

        String findClassification()
        // use myCreditsEarned to determine the student's classification
        // if myCreditsEarned>=90, return "Senior";
        // if 60<=myCreditsEarned<90, return "Junior";
        // if 30<=myCreditsEarned<60, return "Sophomore";
        // if myCreditsEarned<30, return "Freshman".
        {
                // checking creditsEarned and returning the appropriate classification
                if (myCreditsEarned >= 90)
                        return "Senior";
                if (myCreditsEarned >= 60)
                        return "Junior";
                if (myCreditsEarned >= 30)
                        return "Sophomore";
                return "Freshman";

        }
}

Related Solutions

Write a complete program in java that will do the following:
Write a complete program in java that will do the following:Sports:             Baseball, Basketball, Football, Hockey, Volleyball, WaterpoloPlayers:           9, 5, 11, 6, 6, 7Store the data in appropriate arraysProvide an output of sports and player numbers. See below:Baseball          9 players.Basketball       5 players.Football           11 players.Hockey            6 players.Volleyball        6 players.Waterpolo       7 players.Use Scanner to provide the number of friends you have for a team sport.Provide an output of suggested sports for your group of friends. If your...
Modify the attached files to do the following in java: 1) Add all necessary Getters and...
Modify the attached files to do the following in java: 1) Add all necessary Getters and Setters to the Class file. 2) Add code to compare two instances of the class to see which one comes before the other one based on the zipcode. //Address1.java public class Address {    // attributes    private String street, aptNum, city, state;    private int zip;    // constructors    public Address(String street, String aptNum, String city, String state, int zip)    {...
Complete the java program. /* Note: Do not add any additional methods, attributes. Do not modify...
Complete the java program. /* Note: Do not add any additional methods, attributes. Do not modify the given part of the program. Run your program against the provided Homework2Driver.java for requirements. */ /* Hint: This Queue implementation will always dequeue from the first element of the array i.e, elements[0]. Therefore, remember to shift all elements toward front of the queue after each dequeue. */ public class QueueArray<T> { public static int CAPACITY = 100; private final T[] elements; private int...
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1....
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods you...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps:...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods...
Extend the program by adding rules for the following family relationships (add more facts as you...
Extend the program by adding rules for the following family relationships (add more facts as you need ). Rules father(X.Y) > Father (z,w) where X is Y's father father(X,Y):>male(X),Parent(X, Y). brother(X, Y): where X is Y's brother brother(X,Y):-male().praent(X,Y). Brother (y.w) sister(X,Y):-famale(X),praent(X, Y). sister(X, Y): where X is Y's sister Sister(w.y) son(X, Y)> son(X,Y):-male(X), praent(Y,X). where X is Y's son Son(y.z) daughter(X, Y) :- Daughter (w,x) where X is Y's daughter daughter(X,Y):-famale(X), praent(Y.X). where X and Y are sibling Sibling(X, Y):-praent(X,Y),...
Create Lab project Add the following codes to your main method. Compile and run the program...
Create Lab project Add the following codes to your main method. Compile and run the program with some arguments and observe the output.       printf("You have entered %d arguments.\n", argc);       for (int i = 0; i < argc; ++i)         printf( "argument %d: %s\n",i+1,argv[i]); Create a function called simpleFileWrite() and add the following feature: Open a write only file called “myfile.txt” and write characters into it. The set of characters are read form the keyboard until cntrl-z is entered. (use...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user to enter the name of the month he/she was born in (example: September). b) Prompt the user to enter his/her weight in pounds (example: 145.75). c) Prompt the user to enter his/her height in feet (example: 6.5). d) Display (print) a line of message on the screen that reads as follows: You were born in the month of September and weigh 145.75 lbs. and...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user to enter a six-digit integer. b) Take the integer and break it up into two pieces of three-digits each (make sure you keep the order of digits). c) Display each 3-digit piece on a separate line with a proper message before each piece. For example, if the user enters  450835 as the integer, then the program should display the following output: Right 3-digit piece: 835...
JAVA programming language Please add or modify base on the given code Adding functionality Add functionality...
JAVA programming language Please add or modify base on the given code Adding functionality Add functionality for multiplication (*) Adding JUnit tests Add one appropriately-named method to test some valid values for tryParseInt You will use an assertEquals You'll check that tryParseInt returns the expected value The values to test: "-2" "-1" "0" "1" "2" Hint: You will need to cast the return value from tryParseInt to an int e.g., (int) ValidationHelper.tryParseInt("1") Add one appropriately-named method to test some invalid...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT