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...
-
Consider the following diagram. A porous container (A), filled with air at STP, is contained in a large enclosed container (B), which is flushed with H2(g). What will happen to the pressure inside...
-
Explain why economists believe that indifference curves are convex. Give as many reasons as you can?
-
What are two ways of expressing the rate of return on investment?
-
Patty Banyan is a single taxpayer living at 543 Space Drive, Houston, TX 77099. Her Social Security number is 466-33-1234. For 2018, Patty has no dependents, and her W-2, from her job at a local...
-
BBB Inc. expects to pay dividends of $ 1 . 1 0 , $ 1 . 2 1 , and $ 1 . 3 3 in one, two, and three years, respectively. After that, dividends are expected to grow at a constant rate of 4 % forever....
-
(a) Develop a user defined function "MyVar" that calculates a variance by using the following equation: MyVar = 5 17 (3x7 Avg) 2n-1 where Avg represents the average of variable X,. Use the values...
-
A floating rate bond and an inverse floating rate bond are backed by $100 million portfolio of 10-year bonds. The coupon rate on the inverse floater equals: 12% - 2r. The market value of the...
-
Did the salesperson understand the motives behind the purchase? If not, why not? Did s/he make any other mistakes?
-
a. The heading. b. The addressee. c. The first sentence of the opening paragraph. d. The second and third sentences of the opening paragraph. e. The first sentence of the scope paragraph. f. The...
-
a. State the COSO definition of internal control. b. Identify four fundamental concepts reflected in the definition. c. Which entity objectives and related internal controls are of primary relevance...
-
The primary purpose of establishing quality control policies and procedures for deciding whether to accept a new client is to a. Enable the CPA firm to attest to the reliability of the client. b....
-
For the following account balances, what are some specific examples of items that might be considered individually significant because of their nature? a. Accounts receivable b. Inventory c. Property...
-
What is wrong with the following survey question? What is your annual income? $0 - $5,000 $5,001 - $10,000 $10,001 - $25,000 $25,001 - $40,000 $40,001 - $70,000 $70,001 - $100,000 $100,001 or more...
-
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...
-
As the staff accountant at Diablo Manufacturing, you have been asked to prepare the journal entries associated with a recently completed custom order (#720). You have the following information from...
-
Sanchez Consulting applies overhead to consulting projects based on the direct labor hours charged by employees to each job. Selected data for the firm follow: What is the amount of over- or...
-
Given the following data for Scurry Company, what is the cost of goods sold? a. $500,000. c. $800,000. b. $600,000. d. $950,000. Beginning inventory of finished goods Cost of goods manufactured...
Study smarter with the SolutionInn App