Programing

  • Consider the following code segment.
    double purchase = 19.93;
    double payment = 20.00;
    double change = payment – purchase;
    System.out.println(change);
    The code segment prints the change as 0.07000000000000028. Explain why. Give a recommendation to improve the code so that users will not be confused.
  • R2.14 Explain the differences between 2, 2.0, ‘2’, “2”, and “2.0”.
  • R2.15 Explain what each of the following program segments computes.
    a. x = 2;
    y = x + x;b. s = “2”;
    t = s + s;
  • R2.18 Write pseudocode for a program that computes the first and last digit of a number. For example, if the input is 23456, the program should print 2 and 6. Hint: %, Math.log10.
  • R2.19 Modify the pseudocode for the program in How To 2.1 so that the program gives change in quarters, dimes, and nickels. You can assume that the price is a multiple of 5 cents. To develop your pseudocode, first work with a couple of specific values.
  • R2.20 A cocktail shaker is composed of three cone sections.R 2.20 Cocktail Shaker

    Using realistic values for the radii and heights, compute the total volume, using the formula given in Self Check 25 for a cone section. Then develop an algorithm that works for arbitrary dimensions.

  • R2.21 You are cutting off a piece of pie like this, where c is the length of the straight part (called the chord length) and h is the height of the piece.R 2.21 Image

    There is an approximate formula for the area: R 2.21 Formula

    However, h is not so easy to measure, whereas the diameter d of a pie is usually well-known. Calculate the area where the diameter of the pie is 12 inches and the chord length of the segment is 10 inches. Generalize to an algorithm that yields the area for any diameter and chord length.

Don't use plagiarized sources. Get Your Custom Essay on
Programing
Just from $13/Page
Order Essay
Place Order
Grab A 14% Discount on This Paper
Pages (550 words)
Approximate price: -
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Try it now!

Grab A 14% Discount on This Paper

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.