Java programing | Electronic Engineering homework help

This homework assignment is due on Wednesday, September 13, 2017 at 12:00 PM (noon), and will be accepted than 5:00 PM on the same day.

On page 25 of Big Java: Late Objects, complete the following Review Exercises:

  • R1.7 What does this program print?

    public class Test
    {
       public static void main(String[] args)
       {
          System.out.println(“39 + 3”);
          System.out.println(39 + 3);
       }
    }
     

  • R1.7 What does this program print?

    public class Test
    {
       public static void main(String[] args)
       {
          System.out.println(“39 + 3”);
          System.out.println(39 + 3);
       }
    }
     

  • R1.9 What is the compile-time error in this program?

    public class Test
    {
       public static void main(String[] args)
       {
          System.out.println(“Hello”, “World!”);
       }
    }
     

  • R1.13 Write an algorithm to settle the following question: A bank account starts out with $10,000. Interest is compounded monthly at 6 percent per year (0.5 percent per month). Every month, $500 is withdrawn to meet college expenses. After how many years is the account depleted?
    Use the Design Recipe to develop this algorithm.
     
  • R1.14 Consider the question in Exercise R1.13. Suppose the numbers ($10,000, 6 percent, $500) were user selectable. Are there values for which the algorithm you developed would not terminate? If so, change the algorithm to make sure it always terminates.
     
  •  R1.15 In order to estimate the cost of painting a house, a painter needs to know the surface area of the exterior. Develop an algorithm for computing that value. Your inputs are the width, length, and height of the house, the number of windows and doors, and their dimensions. (Assume the windows and doors have a uniform size.)
     
  • R1.19 The ancient Babylonians had an algorithm for determining the square root of a number a. Start with an initial guess of a / 2. Then find the average of your guess g and a / g. That’s your next guess. Repeat until two consecutive guesses are close enough. Write pseudocode for this algorithm.

On pages 26-27 of Big Java: Late Objects, complete the following Practice Exercises:

  • E1.1 Write a program that prints a greeting of your choice, perhaps in a language other than English.
     
  • E1.4 Write a program that prints the balance of an account after the first, second, and third year. The account has an initial balance of $1,000 and earns 5 percent interest per year.
     
  • E1.5 Write a program that displays your name inside a box on the screen.  Do your best to approximate lines with characters such as | – +.
     
  • E1.6 Write a program that prints your name in large letters, such as
    *   *    **    ****    ****   *   *
    *   *   *  *   *   *   *   *  *   *
    *****  *    *  ****    ****    * *
    *   *  ******  *   *   *   *    *
    *   *  *    *  *    *  *    *   *
  • E1.7 Write a program that prints your name in Morse code, like this:
    …. .- .-. .-. -.–
    Use a separate call to System.out.print for each letter.
     
  • E1.8 Write a program that prints a face similar to (but different from) the following:
       /////
      +”””””+
     (| o o |)
      |  ^  |
      | ‘-‘ |
      +—–+
  • E1.10W rite a program that prints a house that looks exactly like the following:
          +
         + +
        +   +
       +—–+
       | .-. |
       | | | |
       +-+-+-+ 
     
  • E1.11 Write a program that prints an animal speaking a greeting, similar to (but different from) the following:
     /_/     —–
    ( ‘ ‘ )  / Hello
    (  –  ) <  Junior |
     | | |   Coder!/
     
  • E1.13 Write a program that prints a poem of your choice. If you don’t have a favorite poem, search the Internet for “Emily Dickinson” or “e e cummings”
     
  • E1.15 Type in and run the following program. Then modify it to show the message “Hello, your name!”.
    import javax.swing.JOptionPane;

    public class DialogViewer
    {
       public static void main(String[] args)
       {
          JOptionPane.showMessageDialog(null, “Hello, World!”);
       }
    }
     

  • E1.16 Type in and run the following program. Then modify it to print “Hello, name!”, displaying the name that the user typed in.
    import javax.swing.JOptionPane;

    public class DialogViewer
    {
       public static void main(String[] args)
       {
          String name = JOptionPane.showInputDialog(“What is your name?”);
          System.out.println(name);
       }
    }
    E1.17 (OPTIONAL) Modify the program from Exercise E1.16 so that the dialog continues with the message “My name is Hal! What would you like me to do?” Discard the user’s input and display a message such as
    I’m sorry, Dave. I’m afraid I can’t do that.
    Replace Dave with the name that was provided by the user.

    E1.18 Type in and run the following program. Then modify it to show a different greeting and image.
    import java.net.URL;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;

    public class Test
    {
       public static void main(String[] args) throws Exception
       {
          URL imageLocation = new URL(
                “http://horstmann.com/java4everyone/duke.gif”);
          JOptionPane.showMessageDialog(null, “Hello”, “Title”,
                JOptionPane.PLAIN_MESSAGE, new ImageIcon(imageLocation));
       }
    }

On pages 71-73 of Big Java: Late Objects, complete the following Review Exercises:

  • R2.1 Write declarations for storing the following quantities. Choose between integers and floating-point numbers. Declare constants when appropriate.
    a. The number of days per week

    b. The number of days until the end of the semester

    c. The number of centimeters in an inch

    d. The height of the tallest person in your class, in centimeters

  • R2.2 What is the value of mystery after this sequence of statements?
    int mystery = 1;
    mystery = 1 – 2 * mystery;
    mystery = mystery + 1;
  • R2.3 What is wrong with the following sequence of statements?
    int mystery = 1;
    mystery = mystery + 1;
    int mystery = 1 – 2 * mystery;
  • R2.4 Write the following mathematical expressions in Java.

    R 2.4 Math Expressions

  • R2.5 Write the following Java expressions in mathematical notation.
    a. dm = m * (Math.sqrt(1 + v / c) / Math.sqrt(1 – v / c) – 1);

    b. volume = Math.PI * r * r * h;

    c. volume = 4 * Math.PI * Math.pow(r, 3) / 3;

    d. z = Math.sqrt(x * x + y * y);

  • R2.6 What are the values of the following expressions? In each line, assume that
    double x = 2.5;
    double y = -1.5;
    int m = 18;
    int n = 4;

    a. x + n * y – (x + n) * y

    b. m / n + m % n

    c. 5 * x – n / 5

    d. 1 – (1 – (1 – (1 – (1 – n))))

    e. Math.sqrt(Math.sqrt(n))

  • R2.7 What are the values of the following expressions, assuming that n and m have type int, n is 17, and m is 18?
    a. n / 10 + n % 10

    b. n % 2 + m % 2

    c. (m + n) / 2

    d. (m + n) / 2.0

    e. (int) (0.5 * (m + n))

    f. (int) Math.round(0.5 * (m + n))

  • R2.8 What are the values of the following expressions? In each line, assume that
    String s = “Hello”;
    String t = “World”;

    a. s.length() + t.length()

    b. s.substring(1, 2)

    c. s.substring(s.length() / 2, s.length())

    d. s + t

    e. t + s

  • R2.11 Find at least five compile-time errors in the following program.
    public class HasErrors
    {
       public static void main();
       {
          System.out.print(Please enter two numbers:)
          x = in.readDouble;
          y = in.readDouble;
          System.out.printline(“The sum is ” + x + y);
       }
    }
  • R2.12 Find three run-time errors in the following program.
    public class HasErrors
    {
       public static void main(String[] args)
       {
          int x = 0;
          int y = 0;
          Scanner in = new Scanner(“System.in”);
          System.out.print(“Please enter an integer:”);
          x = in.readInt();
          System.out.print(“Please enter another integer: “);
          x = in.readInt();
          System.out.println(“The sum is ” + x + y);
       }
    }
  • R2.13 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.
     

  • R2.25 For each of the following computations in Java, determine whether the result is exact, an overflow, or a roundoff error.
    a. 2.0 – 1.1

    b. 1.0E6 * 1.0E6

    c. 65536 * 65536

    d. 1_000_000L * 1_000_000L

  • R2.26 Write a program that prints the values
    3 * 1000 * 1000 * 1000
    3.0 * 1000 * 1000 * 1000
    Explain the results.
     
  • R2.27 This chapter contains a number of recommendations regarding variables and constants that make programs easier to read and maintain. Briefly summarize these recommendations.
     

On pages 75-76 of Big Java: Late Objects, complete the following Practice Exercises:

  • E2.1 Write a program that displays the dimensions of a letter-size (8.5 × 11 inches) sheet of paper in millimeters. There are 25.4 millimeters per inch. Use constants and comments in your program.
     
  • E2.2 Write a program that computes and displays the perimeter of a letter-size (8.5 × 11 inches) sheet of paper and the length of its diagonal.
     
  • E2.3 Write a program that reads a number and displays the square, cube, and fourth power. Use the Math.pow method only for the fourth power.
     
  • E2.4 Write a program that prompts the user for two integers and then prints
     
  • E2.5 Enhance the output of Exercise E2.4 so that the numbers are properly aligned:
    Sum:             45
    Difference:      -5
    Product:        500
    Average:         22.50
    Distance:         5
    Maximum:         25
    Minimum:         20
  • E2.6 Write a program that prompts the user for a measurement in meters and then converts it to miles, feet, and inches.
     
  • E2.7 Write a program that prompts the user for a radius and then prints
     
    • The area and circumference of a circle with that radius
    • The volume and surface area of a sphere with that radius
       
  • E2.8 Write a program that asks the user for the lengths of the sides of a rectangle. Then print
     
    • The area and perimeter of the rectangle
    • The length of the diagonal (use the Pythagorean theorem)
       
  • E2.9 Improve the program discussed in How To 2.1 to allow input of quarters in addition to bills.
     
  • E2.10 Write a program that helps a person decide whether to buy a hybrid car. Your program’s inputs should be:
     
    • The cost of a new car
    • The estimated miles driven per year
    • The estimated gas price
    • The efficiency in miles per gallon
    • The estimated resale value after 5 years

      Compute the total cost of owning the car for five years. (For simplicity, we will not take the cost of financing into account.) Obtain realistic prices for a new and used hybrid and a comparable car from the Web. Run your program twice, using today’s gas price and 15,000 miles per year. Include pseudocode and the program runs with your assignment.
       

  • E2.11 Write a program that asks the user to input
     
  • E2.14 Write a program that reads a number between 1,000 and 999,999 from the user and prints it with a comma separating the thousands. Here is a sample dialog; the user input is in color:
    Please enter an integer between 1000 and 999999: 23456
    23,456
  • E2.16 Write a program that reads in an integer and breaks it into a sequence of individual digits. For example, the input 16384 is displayed as
    1 6 3 8 4
    You may assume that the input has no more than five digits and is not negative.
     
  • E2.17 Write a program that reads two times in military format (0900, 1730) and prints the number of hours and minutes between the two times. Here is a sample run. User input is in color.
    Please enter the first time: 0900
    Please enter the second time: 1730
    8 hours 30 minutes

What Do I Hand In?

Once you are done, submit your answers as any one of:

  • MS Word document (.docx or .doc file)
     
  • Rich Text Format document (.rtf file)
     
  • PDF document
     
  • Plain text document (.txt or .text file)
     
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Choose Us

Quality Papers

We value our clients. For this reason, we ensure that each paper is written carefully as per the instructions provided by the client. Our editing team also checks all the papers to ensure that they have been completed as per the expectations.

Professional Academic Writers

Over the years, our Acme Homework has managed to secure the most qualified, reliable and experienced team of writers. The company has also ensured continued training and development of the team members to ensure that it keep up with the rising Academic Trends.

Affordable Prices

Our prices are fairly priced in such a way that ensures affordability. Additionally, you can get a free price quotation by clicking on the "Place Order" button.

On-Time delivery

We pay strict attention on deadlines. For this reason, we ensure that all papers are submitted earlier, even before the deadline indicated by the customer. For this reason, the client can go through the work and review everything.

100% Originality

At Essay Writing Help, all papers are plagiarism-free as they are written from scratch. We have taken strict measures to ensure that there is no similarity on all papers and that citations are included as per the standards set.

Customer Support 24/7

Our support team is readily available to provide any guidance/help on our platform at any time of the day/night. Feel free to contact us via the Chat window or support email: support@acmehomework.com.

Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
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.

Our Services

Essay Writing Help has stood as the world’s leading custom essay writing services providers. Once you enter all the details in the order form under the place order button, the rest is up to us.

Essays

Essay Writing Services

At Essay Writing Help, we prioritize on all aspects that bring about a good grade such as impeccable grammar, proper structure, zero-plagiarism and conformance to guidelines. Our experienced team of writers will help you completed your essays and other assignments.

Admissions

Admission and Business Papers

Be assured that you’ll definitely get accepted to the Master’s level program at any university once you enter all the details in the order form. We won’t leave you here; we will also help you secure a good position in your aspired workplace by creating an outstanding resume or portfolio once you place an order.

Editing

Editing and Proofreading

Our skilled editing and writing team will help you restructure you paper, paraphrase, correct grammar and replace plagiarized sections on your paper just on time. The service is geared toward eliminating any mistakes and rather enhancing better quality.

Coursework

Technical papers

We have writers in almost all fields including the most technical fields. You don’t have to worry about the complexity of your paper. Simply enter as much details as possible in the place order section.