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 congregation X which wants to weigh the medium and entirety enumerate of hours each master departed on Y purpose during the week. Print quenched the instruction in the subjoined coercionmat:

    Name                           Hours

    ——————————

    Ethan                           41

    Lucas                           60

    Liam                            55

    Olivia                          42

    Isla                              58

    ——————————

    Total                            ???

    Average                       ???

    Note: The treasure of “Average” ground should entertain a type float. Other treasures entertain int type.

    Expert Rejoinder

     

    Answer:

    Programme:

    import java.lang.*;
    import java.io.*;
    class EmployeeAvg //main class
    {
    public static unsubstantial main(String args[]) throws IOException
    {
    float entirety =0,avg =0;
    BufferedReader br = upstart BufferedReader(upstart InputStreamReader(System.in));
    System.out.println (“How sundry memorials are you entering?..”);
    int n = Integer.parseInt(br.readLine());
    int [] performance = upstart int [n+1]; // procure the order preferable coercion avoiding the Array protest quenched of jump exception
    String [] calls = upstart 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 performance hours”);
    performance [i] = Integer.parseInt(br.readLine());
    }
    System.out.println (“Emplyee call Gross Salary”);
    // manually i procure the 5 members you can learn the input line
    coercion (int i=1;i<=n ;i++ ) {
    System.out.println (names[i]+” ” +work[i]);
    entirety =entirety + performance[i];
    avg = entirety / n;
    }
    System.out.println (“Entirety ” +total);
    System.out.println (“Medium ” +avg);
    }
    }

    Output: