Many sports have constants embedded in their rules. For example, baseball has 9 innings, 3 outs per inning, 3 strikes in an out, and 4 balls per walk. We might encode the constants for a program involving baseball as follows:
public static final int INNINGS = 9;
public static final int OUTS_PER_INNING = 3;
public static final int SIRIKES_PER_OUT = 3;
public static final int BALLS_PBR_WALK = 4;
For each of the following popular sports, give Java named constants that could be used in a program involving that sport:
■ Basketball
■ American football
■ Soccer
■ Cricket
■ Bowling
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Computer Science: An Overview (12th Edition)
Starting Out with Python (4th Edition)
Absolute Java (6th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- HASKELL PROGRAMMING LANGUAGE QUESTION PLEASE Rock-paper-scissors is a game for two players. Each player chooses an action without knowledge ofthe other’s choice. If the players choose the same action then there is a draw. Otherwise the winneris determined by the following rules: paper beats rock, rock beats scissors, and scissors beats paper.you are going to make a playable Rock-Paper-Scissors game and consider multiplayer tournaments • Please put comments in your code to show what you are answering with each piece ofcode. • You may create auxiliary functions if you like. You may use library functions from Haskell’sstandard library.• Please limit your line lengths to 100 characters max. Please use the following two data types which you can copy-and-paste into your code.data Action = Rock | Paper | Scissors deriving (Eq, Show)data Outcome = Player1Win | Player2Win | Draw deriving ShowAction represents a player’s chosen action and Outcome represents the outcome of playing a game…arrow_forwardExercises: PolymorphismProblem 1. VehiclesWrite a program that models 2 vehicles (Car and Truck) and will be able to simulate driving and refueling them inthe summer. Car and truck both have fuel quantity, fuel consumption in liters per km and can be driven givendistance and refueled with given liters. But in the summer both vehicles use air conditioner and their fuelconsumption per km is increased by 0.9 liters for the car and with 1.6 liters for the truck. Also the truck has a tinyhole in his tank and when it gets refueled it gets only 95% of given fuel. The car has no problems when refueling andadds all given fuel to its tank. If vehicle cannot travel given distance its fuel does not change.Input On the first line - information about the car in format {Car {fuel quantity} {liters per km}} On the second line – info about the truck in format {Truck {fuel quantity} {liters per km}} On third line - number of commands N that will be given on the next N lines On the next N lines –…arrow_forward// Simulates a simple car with operations to drive and check the odometer.public class SimpleCar { // Number of miles driven private int miles; public SimpleCar(){ miles = 0; } public void drive(int dist){ miles = miles + dist; } public void reverse(int dist){ miles = miles - dist; } public int getOdometer(){ return miles; } public void honkHorn(){ System.out.println("beep beep"); } public void report(){ System.out.println("Car has driven: " + miles + " miles"); } }arrow_forward
- PROGRAMMING LANGUAGE: C++ ALSO PUT SCREENSHOTS WITH EVERY TASK. TASK 1 : A class of ten students took a quiz .The grades (integers are in range 0-100) for this quiz are available to you .Determine class average on quiz . TASK 2: Write c++ code that print summery of exam result and decide either student should have makeup class or not .If more then 30% of class fails in exam it’s mean they need a makeup class otherwise they don’t need any makeup class. For class strength take input from user (Hint: take two variables pass and fail) TASK 3: write a c++ that will determine whether a department-store customer has exceeded the credit limit on the charge account .For each customer , following facts are available : Account number (an integer) Balance at beginning of month Total of all items charged by this customer this month Total of all credit applied to this customer’s account this month. Allowed credit limit You are required to use a while structure to input each of these facts ,…arrow_forwardExample: Design an interface and write a program that determines a student's grade according to his grade point average, as follows: GPA 100-90 Excellent, GPA 89-80 Very Good, GPA 79-70 Good, GPA 69-60 Average, GPA 59-50 Acceptable, GPA 49 or less weakarrow_forwardCREATE A FLOWCHART. Creating a Class in C++ // Rectangle.cpp using namespace std; class Rectangle { public: void setWidth(double); void setLength(double); double getLength(); double getWidth(); double calculateArea(); double calculatePerimeter(); private: double length; double width; }; void Rectangle::setLength(double len) { length=len; } void Rectangle::setWidth(double wid) { width=wid; } double Rectangle::getLength() { return length; } double Rectangle::getWidth() { return width; } double Rectangle::calculateArea() { return width*length; } double Rectangle::calculatePerimeter() { return (length+width)*2; }arrow_forward
- This is my question and this is the code in lab 2The 1's are replaced with an E public class 1xam { private int day; private int month; private int year; private int hour; private int minutes; private double maxMarks; private final String type; private final int order; private static int lab1xamCounter = 0; private static int midterm1xamCounter = 0; public static final String LAB_1XAM = "Lab 1xam"; public static final String MIDTERM_1XAM = "Midterm 1xam"; public static final String FINAL_1XAM = "Final 1xam"; public 1xam(String type) { this (type, 0, 0, 0, 0, 0, 0); } public 1xam(String type, double maxMarks) { this (type, maxMarks, 0, 0, 0, 0, 0); } public 1xam(String type, double maxMarks, int day, int month, int year) { this (type, maxMarks, day, month, year, 0, 0); } public 1xam(1xam other) { this (other.getType(), other.getMaxMarks(), other.getDay(), other.getMonth(), other.getYear(), other.getHour(), other.getMinutes()); } public 1xam(String type, double maxMarks,…arrow_forwardLanguage is c++ Assignment 6 C: Minesweeper - Simplified. For many years, computers sold with the Windows operating system would contain a game called M inesweeper. The player would be presented with a grid, where they would have to click an empty part of the map. If they clicked on a hidden mine, the game would be instantly over. However, if they clicked a safe spot, a hint about nearby mines would be displayed and the player would click another spot. The goal would be to flag all the hidden mines without hitting one. (As an aside, many people did not know these rules and just clicked around randomly until they hit a mine)We will be developing a simplified version of this game. You will prompt the user for a grid size and then created a 2D array with equal width and height (C++ students: Check the Appendix for more information on how to do this). You will initialize the 2D char array with each element equallying a ‘?’ symbol. You will then randomly generate one “mine” value per…arrow_forwardFix these codes in order to get the following output: Code: public class Course { private String course_name; public static int count=1000; public int course_number; private String dept_code; private int room_number; public Course() { course_name=""; dept_code=""; room_number=0; //System.out.println(""+course_number); course_number=count++; } public void set_course_name(String name) { course_name=name; } public void set_dept_code(String code) { dept_code=code; } public void set_room_number(int no) { room_number=no; } //getter methods public String get_course_name() { return course_name; } public String get_dept_code() { return dept_code; } public int get_room_number() { return room_number; } public int get_course_number() { return course_number; } void display() { System.out.println(""+course_number+" "+dept_code+" "+course_name+" "+room_number); } } --------------------------------------- //main.java import java.util.*; public class Main { public static void main(String[] args) {…arrow_forward
- Java - Programming Develop a letter-guessing game in this assignment.Requirements:1). When the game begins, generate a random letter between A and Z;2). Display a message "I have a secret letter (A to Z), can you guess what it is?";3). Read the user's answer;4). Compare the user's answer and the random secret letter generated;5). If the user answer is before the random secret letter in the alphabet, display "Incorrect. Trysomething later in the alphabet" and go to Step 2;6). If the user answer is after the random secret letter in the alphabet, display "Incorrect. Trysomething earlier in the alphabet." and go to Step 2;7). If the user answer is the same as the random secret letter, display "Well done. Want to playagain (y/n)?";8). Read the user's answer. If the answer is 'y', go to Step 1. If the answer is 'n', go to Step 9;9). Display "Thanks for playing the game. Goodbye!". The program stops.Run your program several times. Take screenshots. Submit your Java file with the screenshotsarrow_forwardCode in C++ Language As a cashier, you would always hate those times when customers choose to take back their order since you'd always summon your manager and yell, "Ma'am pa-void!" No matter how you hate it, you always have to do it since you have no other choice. Given (1) an array of prices of the items, (2) another array of the items the customer wishes to take back, and (3) the customer's payment, print the change of the customer. Input: The first number indicates the number of items "n" brought to the cashier. The next "n" numbers are the prices of the items. The next number indicates the number of items "m" that the customer wants to take back and not proceed. It is assured that 0 <= m <= n. The next "m" numbers are the items to be void that ranges from item 1 to item "n". The final number is the customer's payment. It is also assured that the given payment >= final price of items. INPUT: 5 103.65 650.95 10.25 1067.30 65.18 2 1 5 2000.00 Output: The change…arrow_forwardFix these codes in order to get the following output: Code: public class rinoel_Course { private String course_name; public static int count=1000; public int course_number; private String dept_code; private int room_number; public Course() { course_name=""; dept_code=""; room_number=0; //System.out.println(""+course_number); course_number=count++; } public void set_course_name(String name) { course_name=name; } public void set_dept_code(String code) { dept_code=code; } public void set_room_number(int no) { room_number=no; } //getter methods public String get_course_name() { return course_name; } public String get_dept_code() { return dept_code; } public int get_room_number() { return room_number; } public int get_course_number() { return course_number; } void display() { System.out.println(""+course_number+" "+dept_code+" "+course_name+" "+room_number); } } --------------------------------------- //main.java import java.util.*; public class rinoel_TestCourse { public static void…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT