Java Final Project

profilebeehawk5
IMH_FinalProjectPt1.zip

__MACOSX/._IMH_FinalProjectPt1

IMH_FinalProjectPt1/IMHMainProgram.java

IMH_FinalProjectPt1/IMHMainProgram.java

import  javax . swing . * ;   
/**
//***********************************************************************
'Project: Final Project 
'Programmer: Isabella Hawkins
'Company Info: ihawkins @mymail .csmd.edu 
'Date: 12/01/2020
'Description:  Part #01.  
'    
'   LINE 1 AT LEAST 3 LINES OF PROGRAM DESCRIPTION
'   LINE 2 AT LEAST 3 LINES OF PROGRAM DESCRIPTION
'   LINE 3 AT LEAST 3 LINES OF PROGRAM DESCRIPTION
'
'   --------------------------------------------------------------------------
'                               HONOR CODE: 
'   I pledge that this program represents my own program code, I have received 
'   help from no one and I have given help to no one.
'-----------------------------------------------------------------------------
'
'  LINE LENGTH - AVOID LINES LONGER THAN 80 CHARACTERS
'  SCALE BELOW IS TO CALIBRATE SCREENSHOTS
'  DO NOT HAVE YOUR CODE OR SCREENSHOT EXTEND BEYOND THE SCALE
0........1.........2.........3.........4.........5.........6.........7.........8
12345678901234567890123456789012345678901234567890123456789012345678901234567890
*/
/*
2)  Main Program (XXXMainProgram.java where XXX is your initials.) – this program will be used to test that 
your Student class works as specified. 
i)  Write a program that asks the user to enter the student information using JOptionPane. 
The program will ask the user to enter 
(1) the student id
(2) the first and last name
(3) the student’s major
(4) the student’s grades – these will be a comma separated list of scores

ii) Create a Student object with the information the user entered. 

iii)Verify with the user the right information was given by using JOptionPane to output the new student object.
*/

public   class   IMHMainProgram   {
     public   static  makeStudent (){
         int  sId ;
         int   Grade ;  

     // get user input 
         String   Id   =   JOptionPane . showInputDialog ( "What is your student ID?" );
         String  first  =   JOptionPane . showInputDialog ( "What is your First Name?" );
         String  last  =   JOptionPane . showInputDialog ( "What is your Last Name?" );
         String  mjr  =   JOptionPane . showInputDialog ( "What is your Major?" );
         String  grd  =   JOptionPane . showInputDialog ( "What are your Grades?" );

        sId  =   Integer . parseInt ( Id );
         Grade   =   Integer . parseInt ( grd );

     //create a student object
         Student  student1  =   new   Student ( Id ,  first ,  last ,  mjr ,  grd );  

     //print student info 
         JOptionPane . showMessageDialog ( student1 . toString ());
     }
}

__MACOSX/IMH_FinalProjectPt1/._IMHMainProgram.java

IMH_FinalProjectPt1/Student.java

IMH_FinalProjectPt1/Student.java

/**
//***********************************************************************
'Project: Final Project 
'Programmer: Isabella Hawkins
'Company Info: ihawkins @mymail .csmd.edu 
'Date: 12/01/2020
'Description:  Part #01.  
'    
'   This class creates a Student class
'   filled with contructors, attributes and methods
'   which allows for a very detailed instance of this class 
'
'   --------------------------------------------------------------------------
'                               HONOR CODE: 
'   I pledge that this program represents my own program code, I have received 
'   help from no one and I have given help to no one.
'-----------------------------------------------------------------------------
'
'  LINE LENGTH - AVOID LINES LONGER THAN 80 CHARACTERS
'  SCALE BELOW IS TO CALIBRATE SCREENSHOTS
'  DO NOT HAVE YOUR CODE OR SCREENSHOT EXTEND BEYOND THE SCALE
0........1.........2.........3.........4.........5.........6.........7.........8
12345678901234567890123456789012345678901234567890123456789012345678901234567890

1)  Student Class (Student.java) – represents a single student. 
a)  The fields for student row:
i)  Student id
ii) First Name 
iii)    Last Name
iv) Major
v)  Grades – this is an array list of int scores
b)  Methods
i)  3 constructors
(1) A no-arg constructor
(2) A constructor that takes:
(a) Student id
(b) First Name 
(c) Last Name
(3) A constructor that takes:
(a) Student id
(b) First Name 
(c) Last Name
(d) Major
(e) Grades
ii) Getters and Setters for Student id, first name, last name, and major
iii)    A method that returns the student’s first and last name with a space between them
iv) A method that returns the student’s average score
v)  A method that returns the student’s grade based on their average score.
(1) The grade will be based on the following:
(a) 90 to 100 is an A
(b) 80 to 89 is a B
(c) 70 to 79 is a C
(d) 60 to 69 is a D
(e) 0 to 59 is an F

*/

public   class   Student   {

     // students attributes :
     int  studentId ;
     String  fname ;
     String  lname ;
     String  major ;  
     int   []  grades ;


     //setters for studentid, first name, last name, & major
     public   void  setFirst ( String  fname )   {
         this . fname  =  fname ;  
     }

     public   void  setLast ( String  lname )   {
         this . lname  =  lname ;  
     }

     public   void  setMajor ( String  major )   {
         this . major  =  major ;  
     }

     public   void  setId ( int  studentId )   {
         this . studentId  =  studentId ;  
     }

     //getters 
     public   String  getFirst ()   {
         return   this . fname ;
     }

     public   String  getLast ()   {
         return   this . lname ;
     }

     public   String  getMajor ()   {
         return   this . major ;
     }

     public   String  getId ()   {
         return   this . studentId ;
     }

     //student's constructors:
     public   Student1 ()   {
         //no argumens--default student
        studentId  =   1234 ;
        fname  =   "John" ;
        lname  =   "Doe" ;
        major  =   "general studies" ;
        grades  =   [ 30 ,   40 ,   50 ,   60 ,   70 ];
     }

     public   Student ( Id ,  first ,  last )   {
        studentId  =   Id ;
        fname  =  first ;
        lname  =  last ;
     }

     public   Student ( Id ,  first ,  last ,  mjr ,  grd )   {
        studentId  =   Id ;
        fname  =  first ;
        lname  =  last ;
        major  =  mje ;
        grades  =  grd ;
     }

     //methods : 
     //return the student's first and last name
     public   void  getName ( this . fname ,   this . lname )   {
         return  fname  +   " "   +  lname ;
     }
     // get the student's average grade
     public   void  averageScore ( this . grades )   {
         for   ( =   0 ;  i <  grades . length  -   1 ;  i ++ )   {
             int  total  +=  grades [ i ];
         }

         int  average  =  total ;
         return  average ;

     }
     // get the student's overall grade 
     public   void  getGrade ( this . averageScore )   {
         if   ( averageScore  >=   90   ||  averageScore  <=   100 )   {
             char  grade  =   'A' ;
             return  grade ;
         }
        elseif  ( averageScore  >=   80   ||  averageScore  <=   89 )   {
             char  grade  =   'B' ;
             return  grade ;
         }
        elseif  ( averageScore  >=   70   ||  averageScore  <=   79 )   {
             char  grade  =   'C' ;
             return  grade ;
         }
        elseif  ( averageScore  >=   60   ||  averageScore  <=   69 )   {
             char  grade  =   'D' ;
             return  grade ;
         }
         else   {
             char  grade  =   'F' ;
             return  grade ;
         }
     }
     // returns the students profile 
     public   void  toString ()   {
         System . out . println (
             "Student Id: "   +   this . studentId + "\n"   +
             "Name: "   +   this . fname  +   " "   +   this . lname + "\n"   +
             "Major: "   +   this . major + "\n"   +
             "Scores: "   +   this . grades [] + "\n"   +
             "Average Scores: "   +   this . averageScore () + "\n" +
             "Grade: " +   this . getGrade ()
         );
     }
}

__MACOSX/IMH_FinalProjectPt1/._Student.java