Java Tasks 4 - Mr. Benshoof

advertisement
Java Tasks 4 AP Computer Science The following tasks should be completed and turned in electronically by this Friday. 1. Drivers are concerned with the mileage their automobiles get. One driver has kept track of several tankfulls of gasoline by recording the miles driven and gallons used for each tankfull. Develop a java application that will input the miles driven and gallons used (both as integers) for each tankfull. The program should calculate and display the miles per gallon obtained for each tankfull and print the combined miles per gallon obtained for all tankfulls up to this point. All averaging calculations shoud produce double results. Use class Scanner and sentinel controlled repetition to obtain the data from the user. 2. Develop a Java application that will determine whether any of several department-­‐store customers has exceeded the credit limit on a charge account. For each customer, the following facts are available: a. Account number b. Balance at the beginning of the month c. Total of all items charged by a customer this month (money added) d. Total of all credits applied to the customer’s account this month e. Allowed credit limit The program should input all these facts as integers, calculate the new balance (= beginning balance +charges – credits), display the new balance and determine whether the new balance exceeds the customer’s credit limit. For those customers whose credit limit is exceeded, the program should display the message “Credit limit exceeded”. 3. Write a Java application that uses looping to print the following table of values: N 10*N 100*N 1000*N 1 10 100 1000 2 20 200 2000 3 30 300 3000 4. Use looping to let a user enter 10 integers. Then use looping again to find the two largest integers. Return those numbers to the user. 5. Develop a Java application that will determine the gross pay for each of three employees. The company pays straight time for the first 40 hours worked by each employee and time and half for all hours worked in excess of 40 hours. You are given a list of the employees at the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee and should determine and display the employee’s gross (total) pay. 6.1 (This program will grow and develop over the next few weeks. Be sure to take your time, comment well, and save it in a place that you can find it. We’ll be adding to it over the next three or four weeks!) Lathrop’s New Zoo: Lathrop has recently decided to turn the track and football field into a zoo, figuring that it will be useful when the biology classes want to go on a field trip. The thing is, there are a lot of important parts to managing a zoo. The first thing to be concerned about are the animals. Create a complete Java class called zooAnimal. This class should include the following: A useful constructor. At least 5 meaningful private variables, with at least 1 String, 1 int, and 1 boolean. At least 5 meaningful methods other than set and get methods (which should be included as needed). Create a meaningful/useful .toString method as the 6th method of the class. Also create a test class called lhsZoo. In this test class, create at least 6 different animals. Use this test class to show that your zooAnimal class works properly. 
Download