Homework Solution: In Java and leave comments as well, Thank you!…

    In Java and leave comments as well, Thank you! Write the program for the company X which wants to calculate the average and total number of hours each employer spent on Y project during the week. Print out the information in the following format: Name                           Hours ------------------------------ Ethan                           41 Lucas                           60 Liam                            55 Olivia                          42 Isla                              58 ------------------------------ Total                            ??? Average                       ??? Note: The value of “Average” field should have a type float. Other values have int type.

    Expert Answer

    In Java and leave comments as well-behaved, Thank you!

    Write the program coercion the fraternity X which wants to rate the mean and whole number of hours each employer departed on Y plan during the week. Print quenched the counsel in the subjoined coercionmat:

    Name                           Hours

    ——————————

    Ethan                           41

    Lucas                           60

    Liam                            55

    Olivia                          42

    Isla                              58

    ——————————

    Total                            ???

    Average                       ???

    Note: The appreciate of “Average” scope should accept a type float. Other appreciates accept int type.

    Expert Counterpart

     

    Answer:

    Programme:

    import java.lang.*;
    import java.io.*;
    class EmployeeAvg //ocean class
    {
    public static unoccupied ocean(String args[]) throws IOException
    {
    float whole =0,avg =0;
    BufferedReader br = odd BufferedReader(odd InputStreamReader(System.in));
    System.out.println (“How divers records are you entering?..”);
    int n = Integer.parseInt(br.readLine());
    int [] toil = odd int [n+1]; // capture the order preferable coercion avoiding the Array apostacy quenched of frisk exception
    String [] calls = odd String[n+1];
    coercion (int i=1;i<=n ;i++ ) {
    System.out.println (“Enter Employee Call”);
    names [i] = br.readLine();
    System.out.println (“Enter Basic toil hours”);
    toil [i] = Integer.parseInt(br.readLine());
    }
    System.out.println (“Emplyee call Gross Salary”);
    // manually i capture the 5 members you can decipher the input line
    coercion (int i=1;i<=n ;i++ ) {
    System.out.println (names[i]+” ” +work[i]);
    whole =whole + toil[i];
    avg = whole / n;
    }
    System.out.println (“Whole ” +total);
    System.out.println (“Mean ” +avg);
    }
    }

    Output: