1. Create a class called GtStudent that has the following instance data: name: The name of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Create a class called GtStudent that has the following instance data: name: The name of the student. Should be represented as a constant String value since a student's name should not change after being set. gtid: This should be an int that represents the student's GT Id (i.e. 903xxxx). classYear: This should be an int value between [1, 4] that represents the student's year in college. a. b. С. gpa: This should be a double between [0.0, 4.0] that represents the student's grade point average. e. diningDollar: Should be a double that represents the student's current amount of dining dollars d. f. buzzfund: Should be a double that represents the student's current amount of buzzfunds All of the above variable should have correct visibility to enforce the principle of encapsulation. Gtstudent should have the following constructors: It must be possible to create a student with the following combinations of initial data provided as g. 2. a. parameters on construction i. name, gtid, classYear, gpa, diningDollar, buzzfund ii. name, gtid, classYear iii. name, diningDollar, buzzfund iv. name v. GtStudent, name: this constructor should create a GtStudent that has the same instance data as the passed in GtStudent except for name A name b. the student must always be provided on construction с. The default value for gtid must be -1 when not provided on construction or if the provided parameter is invalid (not a 903xxxxxx number) Page < 2 <> of 4 ZOOM + d. The default value for classYear must be 1 when not provided on construction or if the provided parameter is invalid (not [1,4]) e. The default value for diningDollar and buzzfund must both be 0.0 when not provided on construction or if the provided parameter is negative. f. The default gpa must be 4.0 when not provided on construction or if the provided parameter is invalid ([1.0, 4.0]) Note: Constructor chaining MUST be used where possible. g. 3. GtStudent should have the following instance methods: Below you are given the method signatures and specification for the Student class. Make sure these are instance methods and the signatures match exactly. a. purchaseMeal (double cost): i. Reports whether there are enough funds to purchase the meal and updates the student's funds accordingly. The cost should be deducted from the object's diningDollar first and from buzzfund only when the dining dollars are no longer available. If a student has 5.0 dining dollars and 5.0 buzzfunds, and attempts to purchase a meal costing 7.0, they should end up with 0 dining dollars and 3.0 buzzfunds. ii. Prints out when the cost is successfully deducted by the appropriate fund variable: "(name} has successfully purchased the meal" 1. There is a newline character at the end of the String 2. {name} should be the name of the student iii. If there are not enough funds to purchase the meal, prints out: "{name} does not have enough funds to purchase the meal" 1. There is a newline character at the end of the String {name} should be the name of the student b. addDiningDollars (double diningDollar) : Adds the passed in amount of diningDollar to the instance field diningDollar uble buzzfund) : addBuzzfund ( Adds the passed in amount of buzzfund to the instance field buzzfund d. increaseClassYear (): Increments the current classYear of the Student object by 1, if the classYear is 4, then it should remain as 4 NOTE THE FOLLOWING: You must use the exact method signatures provided above If we did not explicitly specify what a method should return you can assume it returns nothing Page < <> of 4 ZOOM If we did not explicitly specify what a method should return you can assume it returns nothing Creating CourseSection 1. Create a class called Coursesection that has the following instance data: a. subject: a String that represents the course subject (ex. CS) b. courseNumber: an int that represents the course number (ex. 1331) C. roster: an array of GtStudents that are enrolled in the course d. numstudents: a long that represents the number of students in the course 2. Constructor that takes in parameters for all of the above instance data 3. CourseSection must contain a static int constant field MAX_ENROLL that is set to 400 4. CourseSection must contain a static int field numsections that maintains how many CourseSections have been created. 5. CourseSection must have the following instance methods: a. addstudent (Gtstudent student): adds the student to the roster if the roster hasn't reached capacity. This should also increment the number of students enrolled in the course. NOTE THE FOLLOWING: Sample Test Cases • There will be no test cases provided, try creating GtStudent Objects and test your code. It is highly recommended that you create a driver class to test your code so you can ensure encapsulation. (a driver class is just a regular class declared as public class Driver, and doesn't have any special powers) Chockstvle 1. Create a class called GtStudent that has the following instance data: name: The name of the student. Should be represented as a constant String value since a student's name should not change after being set. gtid: This should be an int that represents the student's GT Id (i.e. 903xxxx). classYear: This should be an int value between [1, 4] that represents the student's year in college. a. b. С. gpa: This should be a double between [0.0, 4.0] that represents the student's grade point average. e. diningDollar: Should be a double that represents the student's current amount of dining dollars d. f. buzzfund: Should be a double that represents the student's current amount of buzzfunds All of the above variable should have correct visibility to enforce the principle of encapsulation. Gtstudent should have the following constructors: It must be possible to create a student with the following combinations of initial data provided as g. 2. a. parameters on construction i. name, gtid, classYear, gpa, diningDollar, buzzfund ii. name, gtid, classYear iii. name, diningDollar, buzzfund iv. name v. GtStudent, name: this constructor should create a GtStudent that has the same instance data as the passed in GtStudent except for name A name b. the student must always be provided on construction с. The default value for gtid must be -1 when not provided on construction or if the provided parameter is invalid (not a 903xxxxxx number) Page < 2 <> of 4 ZOOM + d. The default value for classYear must be 1 when not provided on construction or if the provided parameter is invalid (not [1,4]) e. The default value for diningDollar and buzzfund must both be 0.0 when not provided on construction or if the provided parameter is negative. f. The default gpa must be 4.0 when not provided on construction or if the provided parameter is invalid ([1.0, 4.0]) Note: Constructor chaining MUST be used where possible. g. 3. GtStudent should have the following instance methods: Below you are given the method signatures and specification for the Student class. Make sure these are instance methods and the signatures match exactly. a. purchaseMeal (double cost): i. Reports whether there are enough funds to purchase the meal and updates the student's funds accordingly. The cost should be deducted from the object's diningDollar first and from buzzfund only when the dining dollars are no longer available. If a student has 5.0 dining dollars and 5.0 buzzfunds, and attempts to purchase a meal costing 7.0, they should end up with 0 dining dollars and 3.0 buzzfunds. ii. Prints out when the cost is successfully deducted by the appropriate fund variable: "(name} has successfully purchased the meal" 1. There is a newline character at the end of the String 2. {name} should be the name of the student iii. If there are not enough funds to purchase the meal, prints out: "{name} does not have enough funds to purchase the meal" 1. There is a newline character at the end of the String {name} should be the name of the student b. addDiningDollars (double diningDollar) : Adds the passed in amount of diningDollar to the instance field diningDollar uble buzzfund) : addBuzzfund ( Adds the passed in amount of buzzfund to the instance field buzzfund d. increaseClassYear (): Increments the current classYear of the Student object by 1, if the classYear is 4, then it should remain as 4 NOTE THE FOLLOWING: You must use the exact method signatures provided above If we did not explicitly specify what a method should return you can assume it returns nothing Page < <> of 4 ZOOM If we did not explicitly specify what a method should return you can assume it returns nothing Creating CourseSection 1. Create a class called Coursesection that has the following instance data: a. subject: a String that represents the course subject (ex. CS) b. courseNumber: an int that represents the course number (ex. 1331) C. roster: an array of GtStudents that are enrolled in the course d. numstudents: a long that represents the number of students in the course 2. Constructor that takes in parameters for all of the above instance data 3. CourseSection must contain a static int constant field MAX_ENROLL that is set to 400 4. CourseSection must contain a static int field numsections that maintains how many CourseSections have been created. 5. CourseSection must have the following instance methods: a. addstudent (Gtstudent student): adds the student to the roster if the roster hasn't reached capacity. This should also increment the number of students enrolled in the course. NOTE THE FOLLOWING: Sample Test Cases • There will be no test cases provided, try creating GtStudent Objects and test your code. It is highly recommended that you create a driver class to test your code so you can ensure encapsulation. (a driver class is just a regular class declared as public class Driver, and doesn't have any special powers) Chockstvle
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Create a base class called Vehicle that has the manufacturer's name (type String), number of cylinders in the engine (type int), and owner (type Person given in Listing 8.1Truck that is derived from...
-
Create a class called Heater, that contains four fields, temperature, increment, max and min, all of whose type is double. Make sure you write a description of your new Class in the comments, with...
-
Create a row vector that has the following elements: 8, 10/4, 12 1.4, 51, tan85, 26, and 0.15.
-
Selecting the best-suited HVAC system depends on factors such as: cost and availability of the energy source; appliance or system efficiency; cost to purchase, install, and maintain the appliance or...
-
You are the assistant to Julie Davidson, the sales manager of Old Reliable Life Insurance Company. Julie is interested in equipping her sales force with the technology they need to sell Old Reliables...
-
The 2008 balance sheet of Maria's Tennis Shop, Inc., showed long-term debt of $2.6 million, and the 2009 balance sheet showed long-term debt of $2.9 million. The 2009 income statement showed an...
-
In the axon model of Figure 23.50, if the thickness of the myelin sheath were increased, the propagation speed of nerve impulses would A. Increase. B. Decrease. C. Remain the same. FIGURE 23.50 A...
-
After computing the current periods basic and diluted EPS figures, you notice that while basic EPS continues its upward trend, diluted EPS has dropped slightly. In discussions with your manager...
-
(c) (10 pts) Suppose that the fund manager just shorted another portfolio worth of $10 million with a beta of 1.2, what position in the futures should the fund manager take now to make the combined...
-
Right Company purchased 25,000 common shares (25%) of ON Inc. on January 1, Year 11, for $250,000. Right uses the equity method to report its investment in ON because it has significant influence in...
-
What is the protein molecular composition of human skin?
-
Compute the IRR for Project F. The appropriate cost of capital is 13 percent. (Do not round intermediate calculations and round your final answer to 2 decimal places.) Project F Time: Cash flow: IRR...
-
You have been asked to cater a party and bake your famous Chocolate Chunk Brownies. Your Original recipe will make 96 brownies, however, that is not enough to feed the 250 guests. Determine the...
-
On 1 January 20X9, a borrower signed a long-term note, face amount, $1,750,000; time to maturity, three years; stated ra 2%. The effective rate of interest of 7% determined the cash received by the...
-
The height of an object dropped from the roof of an eight story building is modeled by h(t)=-16t2+64, 0 2. Here, h is the height of the object off the ground, in feet, t seconds after the object is...
-
Incomplete financial statements for Sunland Inc. follow. (a) Calculate the missing amounts for [1] to [13]. Note that you may not be able to solve the items in numerical order. Service revenue...
-
What language (a subset of {a,b}*) is generated by the context-free grammar with the indicated productions? (a) [2 points] S SaS | b (b) [2 points] S SaS | b|e (c) [2 points] S TT and TaT | Ta | b...
-
Identify the source of funds within Micro Credit? How does this differ from traditional sources of financing? What internal and external governance mechanisms are in place in Micro Credit?
-
A twin primes is a pair of prime numbers such that the difference between them is 2 (for example, 17 and 19). Write a computer program that finds all the twin primes between 10 and 500. The program...
-
The average monthly precipitations (in) for Boston and Seattle during 2012 are given in the vectors below (data from the U.S. National Oceanic and Atmospheric Administration). BOS = [2.67 1.00 1.21...
-
An elliptical staircase that decreases can be modeled by the parametric equations x = rcos(t) y = rsin(t) z = ht/n where r = ab/[bcos(t)2 + [asin(t)2, a and b are the semimajor and semiminor axes of...
-
Using the knowledge you gained from your interview in mini case 1 , design an interface for the individual you interviewed. What interface design modifications are you making so that the program will...
-
The line depicting the risk and return of portfolio combinations of a risk-free asset and any risky asset is the: A. Security market line. B. Capital allocation line. C. Security characteristic line.
-
Relative to portfolios on the CML, any portfolio that plots above the CML is considered: A. Inferior. B. Inefficient. C. Unachievable.
Study smarter with the SolutionInn App