اذهب إلى المحتوى

ليلى

الأعضاء
  • المساهمات

    9
  • تاريخ الانضمام

  • تاريخ آخر زيارة

  • عدد الأيام التي تصدر بها

    2

أجوبة بواسطة ليلى

  1.  Problem Description: Given an input text file, you have to read this file, gets all the vowels in the file (A, E, I, O, U) and store them in a map data structure. Your map should consider the exact location of the key (its row number and its column number in the text) as the key of each vowel. The value of the vowel should be its value in the upper case form.

    Read a text file whose location is inputted by the user. 

    Get each vowel in the text file.

    . Create a map which stores information about the extracted vowels as follows:

    a. The key stores the location of the vowel in the text file. The location includes the row number and the column number of the vowel in the text file

    b. The value stores the vowel itself, but in lower case..

    4. Make sure that your map sorts the vowels alphabetically using their values.

    5. Make all the vowels in uppercase and modify them in their corresponding location in the text file

     

     

  2.  public static double power(double x, int n) {//method power 
            if (n == 0) {
                return 1;
            } else {
                return x * power(x, n - 1);
            }
    
        }
    //method fact number 
        public static int factorial(int n) {
            if (n == 0) {
                return 1;
            } else {
                return n * factorial(n - 1);
            }
        }
    
        public static double myexp(double x, int n) {
            if (n == 0) {
                return 1;
            } else {
                return (power(x, n) / factorial(n)) + myexp(x, n - 1);
            }
        }
    //main 
        public static void main(String[] args) {
            int n = 10;
            double x = 1;
            System.out.println(myexp(x, n)); // unfortunately, increasing n value
                                                // makes it go infinite.
        }}

     

×
×
  • أضف...