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...
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...
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...
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),...
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...
Given the following program(Java); we are asked to do the following 1. Add a loop in...
Given the following program(Java); we are asked to do the following 1. Add a loop in the main to enqueue 12 items of your choice. 2. Be sure to implement some form of error checking that lets you know if the loop tries to add too many items to the queue. Error message: "Unexpected overflow" 3. Add a loop to dequeue items and print them on their own line with their location. Location = ? item = ? package Khatrijavaarrayqueue;...
Write a Java program to encrypt the following message using the RC4 cipher using key CODES:...
Write a Java program to encrypt the following message using the RC4 cipher using key CODES: Cryptography is a method of protecting information and communications through the use of codes so that only those for whom the information is intended can read and process it. Instead of using stream length 256, we will use length 26. When encrypting, let A = 0 to Z = 25 (hence CODES = [2 14 3 4 18]). Ignore spaces and punctuations and put...
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread...
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread prints all capital letters 'A' to'Z'. The other thread prints all odd numbers from 1 to 21.
Complete the provided C++ program, by adding the following functions. Use prototypes and put your functions...
Complete the provided C++ program, by adding the following functions. Use prototypes and put your functions below main. 1. Write a function harmonicMeans that repeatedly asks the user for two int values until at least one of them is 0. For each pair, the function should calculate and display the harmonic mean of the numbers. The harmonic mean of the numbers is the inverse of the average of the inverses. The harmonic mean of x and y can be calculated...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT