COSC 60 – Lab 4 (Spring 2009)

(1) An Internet service provider has three different subscription packages for its customers:

Package A: For $ 9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.

Package B: For $ 13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.

Package C: For $ 19.95 per month unlimited access is provided.

Write a java application that calculates a customer’s monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. It should then display the total charge.

A sample dialog is given below. User input is shown in bold

Please enter the package name : A

Please enter the hours that were used : 12

The output is :

13.95

(2) Write a java program that reads a line of text and then outputs the line of text with the first occurrence of “hate” changed to “love”. You can assume that the word “hate” occurs in the input. If the word “hate” occurs more than once in the line, your program should replace only the first occurrence of “hate”.

A sample dialog is given below. User input is shown in bold

Please enter a line of text : I hate you

I have rephrased that line to read:

I love you

Note: Your programs should be neat and well documented. Follow all the java style and documentation guidelines explained in class and in your text book.

Submission: Show (i) pseudo code, (ii) source code, and (iii) sample run of all your programs to the TA.