1) Through BlueJ, write if the current number of shoppers is greater than or equal to the number leaving then the number of shoppers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of shoppers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the message.
2) The class must define a method called leaving that takes a single integer parameter. This represents the number of shoppers leaving the club at a particular point. You may assume that the parameter's value will always be greater than zero and you do not have to check for that. If the current number of clubbers is greater than or equal to the number leaving then the number of clubbers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of clubbers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the error message.
3) The class must define a method called is Space that allows the night club staff to determine whether there is enough capacity for a group to attend. This method must take a single integer parameter representing the size of the group, and return a boolean result. The method must work as follows: If the value of the parameter is less-than or equal-to 0 then the method must return false. This case has priority over those following. If the value of the parameter is less-than or equal-to the space left in the night club (use the capacity and occupancy values in the to work this out) then the method must return true. Otherwise (i.e., if there is not space in the night club for the whole group) then the method must return false. (Note that the method must only return true if there is space for the whole group to attend. This method must not change the state of the BookClub object. In other words, both the current number of occupants and the capacity of the club must be exactly the same after it is called as it was before.)
Step by stepSolved in 5 steps with 3 images
- Please written by computer sourcearrow_forwardbox1 and box2 are instances of the Box class. Attributes length, width, and height of both box1 and box2 are read from input. Then, two strings are read from input. In the Box class, define instance method print_measurements() with self and one string as parameters to output the string parameter in one line, and the following in the next line: The value of attribute length ' by ' The value of attribute width ' by ' The value of attribute heightarrow_forwardJAVA write grading program for a class with the following grading policies. thers a total of 2 quizzes, each graded on the basis of 10 points. theeres is 1 midterm exam and one final exam, each graded on the basis of 100 points. final exam counts for 50% of the grade, the midterm counts for 25%, and the 2 quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores.) letter grade will be given based on the following criterion: 90 – 100 A 80 – 89 B 70 – 79 C 60 – 69 D 0 – 59 E program will read student’s scores from a txf file, save them in an arrayor arrays), process the arrays), print the student’s record, which consists of the name, 2 quiz and 2 exam scores as well along with students avg numscore for the course and final letter rade. please noteAll the scores are integers and a student name consists of no more than 10 characters. justify output filearrow_forward
- Python Programming (code) Write a class named "Fraction" that represents a rational number (a number that can be expressed as the quotient of two integers). Implement the following methods: The __init__(self, numerator, denominator) method should accept integer values for the numerator and denominator arguments and set instance attributes of the same name. If the denominator is 0, raise a ZeroDivisionErrorexception. Use the [math.gcd](https://docs.python.org/3/library/ math.html#math.gcd) function to find the greatest common divisor (GCD) of the numerator and de- nominator and then divide each of them by it to "normalize" the fraction. For example, the fraction 28/20 will get normalized to 7/5 since the GCD of 28 and 20 is 4: >>> x = Fraction(28, 20) >>> x Fraction(7, 5) Implement the basic binary operators (+,-,*,/) so that a Fraction can be combined with either another fraction or an integer. All methods should return a new Fraction. Note that you may need…arrow_forwardWrite a class that contains the following two methods: /** Convert from Celsius to Fahrenheit */ public static double celsiusToFahrenheit(double celsius) /** Convert from Fahrenheit to Celsius */ public static double fahrenheitToCelsius(double fahrenheit) The formula for the conversion is as follows: fahrenheit = (9.0 / 5) * celsius + 32 celsius = (5.0 / 9) * (fahrenheit – 32) Write a test program that invokes these methods to display the following table: NOTE: Celsius starts at 40 and should be converted to Fahrenheit, on the same line Fahrenheit starts at 120 and should be converted to Celsius Do not forget to Introduce your Program to the user with descriptive information. Do not forget to include a block Comment header at the start of your Source Code.arrow_forwardNeed help asap:arrow_forward
- Which of the following most precisely describes what: assertEquals(expected, actual); means in a test function? A. If the two values are not equal, the test fails. If they are equal, the test does not necessarily pass B. If the two values are equal, the test passes. If they are not equal, the test does not necessarily fail C. We cannot know for certain without more information OR the method assertEquals doesn't exist. D. If the values are equal, the test passes. If the two values are not equal, the test fails.arrow_forward2arrow_forwardWrite a method for the farmer class that allows a farmer object to pet all cows on the farm. Do not use arrays.arrow_forward
- Problem: To write the JUnit test cases for our methods, you need to create two test methods: testLeapYear: This method should test if the isLeapYear method returns true for a given leap year. For example, you can choose the year 2020 and verify if the method returns true for it. If it does, the test will pass. If it doesn't, the test will fail. testNotLeapYear: This method should test if the isLeapYear method returns false for a given non-leap year. For example, you can choose the year 1900 and verify if the method returns false for it. If it does, the test will pass. If it doesn't, the test will fail. --------------------------------------------------------------------------------------------------------------------------------------------------------- import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; public class LeapYearTest { // Test case to check if a year is a leap year @Test public void testLeapYear() { //create…arrow_forwardIn the following code: def foo(value): value = value + 1 def main(): x = 10 foo(x) Ox is a formal parameter and value is an actual parameter. O Both value and x are actual parameters. value is a formal parameter and x is an actual parameter. O There are no parameters.arrow_forwardUsing python: (see attached- I need help with part Q2) Add a method to the person class name it (username) that takes the email and take off all the part from @ and after, and assigns the string before the @ sign to a variable username. For example: malabdullah@UT.edu, the method will assign 'malabdullah' as the username.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education