
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Object Oriented Programming With Java
Typology: Quizzes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

6.18 (Check password) Some websites impose certain rules for passwords. Write a method that checks whether a string is a valid password. Suppose the password rules are as follows: ■■ A password must have at least ten characters ■■ A password consists of only letters and digits. ■■ A password must contain at least three digits. Write a program that prompts the user to enter a password and displays Valid Password if the rules are followed or Invalid Password otherwise. 7.30 (Pattern recognition: consecutive four equal numbers) Write the following method that tests whether the array has four consecutive numbers with the same value: public static boolean isConsecutiveFour(int[] values) Write a test program that prompts the user to enter a series of integers and displays it if the series contains four consecutive numbers with the same value. Your program should first prompt the user to enter the input size—i.e., the number of values in the series. Here are sample runs: 8.2 (Average the major diagonal in a matrix) Write a method that averages all the numbers in the major diagonal in an n * n matrix of double values using the following header: public static double averageMajorDiagonal(double[][] m) Write a test program that reads a 4-by-4 matrix and displays the average of all its elements on the major diagonal. Here is a sample run Arab Academy for Science, Technology & Maritime Transport College of Computing and Information Technology Course: Object-Oriented Programming Lecturer: Dr.Fahima Maghraby , Dr. Emad Elsamahy, Dr. Yasser Omar, Dr. Shereen Ahmed Teaching Assistant: Eng.Maiada, Eng. Nada, Eng.Hagar, Eng.Alaa Sheet: Section 2 Methods 1