MIS 260 Practice - week 7

 

1.      Visit the class web page, and then download DebugEight2 Java files. The file has syntax and/or logical errors. Determine the problem and fix the program.

 

2.      Below is a partially completed program that is designed to store vowels (a, e, i, o, and u) in an array. Fill out the underline blank lines to complete it. The program asks the user to enter a character. Then the program indicates whether the entered character is a vowel.

 

public class VowelArray {

            public static void main (String args[]) throws Exception {

                        char[] vowels = {______________________________ };

 

                        int i = 0;

                        char g = ' ';

                        boolean isVowel = false;

// The functionality of below bolded lines are almost exactly same as the                 

//BufferReader code. Thus, do not concern with these lines….

                        System.out.print("Enter a character: ");

                        g = (char)System.in.read();

                        System.in.read();

                        System.in.read();

 

                        for (_________________________) {

                                                if (g = = vowels[i])

                                                            isVowel = true;

                        }

                        if (_______________________)

                                    System.out.println(g + " is a vowel");

                        else

                                    System.out.println(g + " is NOT a vowel");

            }

}

 

 

Java Assignment 6: (Turn in by email – attach program)

Due: will be announced by instructor

Score: 10 points

 

  1. Visit the class web page, and then download the “IntArray” Java files. Analyze this program (by compiling and executing). Specifically, there are three loops. Explain detail function of each loop as well as relationship and interaction of three loops. Also, (1) explain what the array of this program is design to do, (2) explain what outcome will be displayed, and (3) explain display format of the outcome (why  is the outcome displayed in this way?). Turn in your detail analysis of this program using MS word by email.
     
  2. Write a program that stores consonant in an array. Ask user to enter a character. Then the program should indicate whether the entered character is a consonant. I strongly recommend you to benchmark the question #2 program. But, unlike question#2, you must apply formal way to accept external data and that is a requirement for this program. Save the program as ConsonantArray.java