Suppose direction is an integer angle between 0 and 359 degrees. You turn by a given angle and update the direction as
In which situation do you get the wrong result? How can you fix that without using the Math.floorMod method described in Java 8 Note 2.1?
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with C++: Early Objects (9th Edition)
- The following problem shows up in a number of Java texts, including Savitch's textbook: The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exercise. This is called your basal metabolic rate, or BMR. The calories needed for a woman to maintain her weight is: WBMR = 655 + (4.3 × weight in pounds) + (4.7 × height in inches) − (4.7× age in years) The calories needed for a man to maintain his weight is: MBMR = 66 + (6.3 × weight in pounds) + (12.9 × height in inches) − (6.8 × age in years) A typical chocolate bar will contain around 230 calories. Write a program that allows the user to input his or her weight in pounds, height in inches, and age in years. The program should then output the number of chocolate bars that should be consumed to maintain one’s weight for both a woman and a man of the input weight, height, and age. NOTE: This is an application of a selection statement! Input Data: Use a named constant for the…arrow_forwardWrite a method that takes a RegularPolygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclusive, and sets its side length to a random decimal number greater than or equal to 5 and less than 12. Use Math.random() to generate random numbers. This method must be called randomize() and it must take an RegularPolygon parameter. You can call your method in the program's main method so you can test whether it works, but you must remove or comment out the main method before checking your code for a score. You will also need to make sure you do not remove the import statement "import testing.Math" as this is required to check your code for a score.arrow_forwardBasic Java please Write a method called torusVolume(? littleR, ? bigR) that takes an int littleR and an int bigR in as parameters. Use the two values to find and return the volume as a double of the associated regular octagonal prism. The formula for the volume of a torus is (2πR)⋅(πr^2)arrow_forward
- Please give me the answer with step by step solutionarrow_forwardNancy wants to hang a photo frame of her graduation photo. The ladder is placed at 2 feet away from the wall. The angle that is formed by the wall and the ground is 105 degrees and the angle formed by the center mark and the ladder will be 15 degrees. In Java programming context, use the predefined method(s) in Math class, find the length of the ladder (in 2 decimal format) that Nancy needed in order to put up her graduation photo neatlyarrow_forwardusing java language Your program will identify if the shape is a square or a rectangle. Input the length and width of the shape, and display if it’s a rectangle or square, with its area and perimeter. Use the following methods in your program. inputLength() – returns the input length; inputWidth() – returns the input width; analyze(length,width) – based on the parameters length and width, returns a Boolean value if the shape is square or not compute(length,width) – based on the parameters length and width, display the area and the perimeter of the shape.arrow_forward
- A pentagonal number is defined as n (3 n-1)/ 2 for n= 1, 2,.. so on. Therefore, the first few numbers are 1, 5, 12, 22, .. Write a method with the following header that returns a pentagonal number: puearrow_forwardIn the classic problem FizzBuzz, you are told to print the numbers from 1 to n. However,when the number is divisible by 3, print "Fizz''. When it is divisible by 5, print "Buzz''. When it isdivisible by 3 and 5, print"FizzBuzz''. In this problem, you are asked to do this in a multithreaded way.Implement a multithreaded version of FizzBuzz with four threads. One thread checks for divisibilityof 3 and prints"Fizz''. Another thread is responsible for divisibility of 5 and prints"Buzz''. A third threadis responsible for divisibility of 3 and 5 and prints "FizzBuzz''. A fourth thread does the numbersarrow_forwardWrite a simple calculator which supports add subtract multiply and divide. Prompt the user for two numbers and an operation. Use number 1-4 for menu options. If divide is selected and the second number is zero, output an error message. If an invalid menu option is selected, output an error message. If all is well, perform the operation and output the result to one decimal. Please write in Java that results like test case examples. Thanksarrow_forward
- Write a method that returns the sum of a range of numbers. It should take the starting and ending numbers of the range (inclusive) as parameters. (Use Java) For example: sumRange(0, 5) // returns 15 (0 + 1 + 2 + 3 + 4 + 5 = 15)sumRange(3,10) // returns 55 (3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 52)sumRange(5, 7) // returns 18 (5 + 6 + 7 = 18)arrow_forwardUSING JAVA Write a method intToWeekDay(integer) that returns a week day if integer is belongs to {0,1,...,6} by using enumeration type. For example, calling intToWeekDay(0) returns "Sunday".arrow_forwardDon't change variable names and please don't use the answer on another site. thank youarrow_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