The Artima Developer Community
Sponsored Link

Java Answers Forum
Assignment No. 1

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Nainil Chheda

Posts: 1
Nickname: nainil
Registered: Dec, 2002

Assignment No. 1 Posted: Dec 8, 2002 10:31 PM
Reply to this message Reply
Advertisement
1. Write a Java Application which prints an output such as:

Today is Monday June 18, 2001

Hint: Review the Date class of java.util

2. Solve the following:
a. Write a Java Application to display only those arguments (passed to the main) which end in a vowel.

Hint: Review the String class. It is final class and cannot be subsclassed. Strings content cannot be changed(are immutable)

b. Modify the above to display all arguments which the character 'x' and also to display all arguments in uppercase.

3. Write a Java application to generate, store and sum n elements of a Fibonacci sequence. Do the above in all of the following ways:
a. Just display a sequence element when it is generated and add the element to the cumulative sum. This way you do not use a Collection to store the elements.
b. Use an integer array to store the elements as each one is generated; sum them later and display the result.
c. Use a Vector Collection. The vector class implements the Enumeration interface. Use the Integer wrapper class for int, since only objects can be added to the Vector Collection.
You may derive a class from Vector; specify a constructor with an int argument; specify an init() method which shows the Fibonacci numbers.
Write a print() method which prints them.
Use the Enumeration interface.
Hint:
Review the following:
Wrapper classes
Vector class
Enumeration interface


4. A mail order house sells five differnet products whose retail prices are product 1 - Rs. 50.50, product 2 - Rs. 65.75, product - 3 Rs. 73.45 , product - 4 Rs. 95.99, product - 5 Rs. 105.85. Write an applet that reads a series of pairs of numbers as follows:
a. Product number
b. Quantity sold for one day.

Your program should use a switch structure to help determine the retail price for each product. Your program should calculate and display the total retail value of all products sold last week. Use a TextField to obtain the product number from the user.

5.A parking garage charges a Rs. 10 minimum fee to park for up to three hours. The garage charges an additional Rs. 3 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is Rs. 50. Assume that no car parks for longer than 24 hours at a time. Write an applet that calculates and displays the parking charges for each customer who parked their car in this garage yesterday. You should enter in a TextField 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 yesterday's receipts. The program should use the method calculateCharges to determine the charge for each customer.

6. Write a method squareOfAsterisks that displays a solid square of asterisks whose side is specified in integer parameter side. For example, if side is 4, the method should display:
****
****
****
****
Incorporate this method into an applet that reads an integer value for side from the user at the keyboard and performs the drawing with the squareOfAsterisks method. Note that this method should be called from the applet's paint method and should be passed the Graphics object from the paint method.

Topic: sms functionality Previous Topic   Next Topic Topic: Coding

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use