Question: in java 6 . 7 What is the value of x after each of the following statements is executed? double x = Math.abs ( 7
in java
What is the value of x after each of the following statements is executed?
double x Math.abs;
double x Math.floor;
double x Math.abs;
double x Math.ceil;
double x Math.abs;
double x Math.ceil;
double x Math.ceilMath.abs Math.floor;
Parking Charges A parking garage charges a $ minimum fee to park for up to three hours. The garage charges an additional $ per hour for each hour or part thereof in excess of three hours. The maximum charge for any given hour period is $ Assume that no car parks for longer than hours at a time. Write an application that calculates and displays the parking charges for each customer who parked in the garage yesterday. You should enter the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the running total of yesterdays receipts. It should use the method calculateCharges to determine the charge for each customer.
Rounding Numbers Math.floor can be used to round values to the nearest integereg
double y Math.floorx ;
will round the number x to the nearest integer and assign the result to y Write an application that reads double values and uses the preceding statement to round each of the numbers to the nearest integer. For each number processed, display both the original number and the rounded number.
Rounding Numbers To round numbers to specific decimal places, use a statement like
double y Math.floorx ;
which rounds x to the tenths position ie the first position to the right of the decimal point or
double y Math.floorx ;
which rounds x to the hundredths position ie the second position to the right of the decimal point Write an application that defines four methods for rounding a number x in various ways:
roundToIntegernumber
roundToTenthsnumber
roundToHundredthsnumber
roundToThousandthsnumber
For each value read, your program should display the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth and the number rounded to the nearest thousandth.
Answer each of the following questions:
What does it mean to choose numbers at random
Why is the nextInt method of class SecureRandom useful for simulating games of chance?
Why is it often necessary to scale or shift the values produced by a SecureRandom object?
Why is computerized simulation of realworld situations a useful technique?
Write statements that assign random integers to the variable n in the following ranges:
n
n
n
n
n
n
Write statements that will display a random number from each of the following sets:
Exponentiation Write a method integerPowerbase exponent that returns the value of
base exponent
For example, integerPower calculates or Assume that exponent is a positive, nonzero integer and that base is an integer. Use a for or while statement to control the calculation. Do not use any Math class methods. Incorporate this method into an application that reads integer values for base and exponent and performs the calculation with the integerPower method.
Hypotenuse Calculations Define a method hypotenuse that calculates the hypotenuse of a right triangle when the lengths of the other two sides are given. The method should take two arguments of type double and return the hypotenuse as a double. Incorporate this method into an application that reads values for side and side and performs the calculation with the hypotenuse method. Use Math methods pow and sqrt to determine the length of the hypotenuse for each of the triangles in Fig. Note:Class Math also provides method hypot to perform this calculation.
Fig
Values for the sides of triangles in Exercise
Triangle Side Side
Multiples Write a method isMultiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The method should take two integer arguments and return true if the second is a multiple of the first and false otherwise. Hint: Use the remainder operator. Incorporate this method into an application that inputs a series of pairs of integers one pair at a time and determines whether the second value in each pair is a multiple of the first.
Even or Odd Write a method isEven that uses the remainder operator to determine whether an integer is even. The method should take an integer argument and return true if the integer is even and false otherwise. Incorporate this method into an application that inputs a sequence
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
