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 courteous, Thank you!

    Write the program ce the concourse X which wants to investigate the medium and aggregate number of hours each mistress spent on Y contrivance during the week. Print extinguished the notification in the subjoined cemat:

    Name                           Hours

    ——————————

    Ethan                           41

    Lucas                           60

    Liam                            55

    Olivia                          42

    Isla                              58

    ——————————

    Total                            ???

    Average                       ???

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

    Expert Rejoinder

     

    Answer:

    Programme:

    import java.lang.*;
    import java.io.*;
    class EmployeeAvg //ocean class
    {
    public static lacking ocean(String args[]) throws IOException
    {
    float aggregate =0,avg =0;
    BufferedReader br = fantastic BufferedReader(fantastic InputStreamReader(System.in));
    System.out.println (“How manifold records are you entering?..”);
    int n = Integer.parseInt(br.readLine());
    int [] effect = fantastic int [n+1]; // procure the concatenate upper ce avoiding the Array apostacy extinguished of jump exception
    String [] designates = fantastic String[n+1];
    ce (int i=1;i<=n ;i++ ) {
    System.out.println (“Enter Employee Designate”);
    names [i] = br.readLine();
    System.out.println (“Enter Basic effect hours”);
    effect [i] = Integer.parseInt(br.readLine());
    }
    System.out.println (“Emplyee designate Gross Salary”);
    // manually i procure the 5 members you can decipher the input line
    ce (int i=1;i<=n ;i++ ) {
    System.out.println (names[i]+” ” +work[i]);
    aggregate =aggregate + effect[i];
    avg = aggregate / n;
    }
    System.out.println (“Aggregate ” +total);
    System.out.println (“Medium ” +avg);
    }
    }

    Output: