java programming1 assignment#2...

7
Java programming1 Assignment#2 Methods

Upload: lamnga

Post on 12-Mar-2018

230 views

Category:

Documents


1 download

TRANSCRIPT

Java programming1

Assignment#2 Methods

Programming Exercises:

1. Write a method, reverseDigit, that takes an integer as a parameter and returns the

number with its digits reversed. For example, the value of reverseDigit(12345) is

54321. Also, write a program to test your method.

2. Write a program that reads a student’s name together with his or her test scores.

The program should then compute the average test score for each student and

assign the appropriate grade. The grade scale is as follows: 90-100,A; 80-89,B;

70-79,C; 60-69,D; 0-59,F.

Your program must use the following methods:

a. A value-returning method, calculateAverage, to determine and return the

average of five test scores for each student. Use a loop to read and sum the

five test scores. (This method does not output the average test score. That task

must be done in the method main.)

b. A value-returning method, calculateGrade, to determine and return each

student’s grade. (This method does not output the grade. That task must be

done in the method main.)

3. Write a method int count_vowels(String str) that returns a count of all vowels in

the string str. Vowels are the letters a, e, i, o, and u, and their upper case variants.

4. solve the following problems from the textbook chapter 6:

2, 3, 4,5, 6, 10, 38