\$30.00

Category:

## Description

Objectives:

• Solving problems and designing algorithms

• Defining and invoking methods

• Implementing algorithms with Java methods

Instructions [30 marks]:

1. Create a folder named Lab8 to store all the files from this lab

2. Create an external documentation file (filename: Lab8Ext.docx) to store the summary, algorithm(s), and sample input and output for each problem.

3. All your programs must have good internal and external documentations

Problem 1: [5 marks] Count number of vowels in a sentence

(filename: CountVowels.java)

Write a method that returns the number of vowels (a, e, i, o, u. including both uppercase and lowercase) in a given sentence. In the main method, ask the user to enter a sentence, call the method above, and display the result.

You must design the algorithms for both the user-defined method and the main method.

Problem 2: [10 marks] Converting temperature from Fahrenheit to Celsius

(filename: ConvertFahToCelMethod.java)

Write a program that converts temperature from Fahrenheit to Celsius. After each conversion the user is prompted to answer if he wants to continue or not. If yes, the program asks the user to enter a new temperature and continue.

The conversion from Fahrenheit to Celsius must be implemented through a user-defined method.

You must design the algorithms for both the user-defined method and the main method.

Two sample runs are shown below:

Enter a temperature in Fahrenheit: 100

The temperature in Celsius is: 37.78

Do you want to continue? y

Enter a temperature in Fahrenheit: 32

The temperature in Celsius is: 0.00

Do you want to continue? n

Write a method that checks whether a given password is valid. A valid password must contain at least 8 characters. It must also contain at least one uppercase letter, at least two digits, and at least one of these four special characters (\$, #, !, &).

In the main method, ask the user to enter a password, call the method above, and display whether the password is valid.

You must design the algorithms for both the user-defined method and the main method.

What to hand in

Zip the folder which contains the documentation file and all the Java source files from this lab and submit the zipped folder to BrightSpace.

.