Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An amateur pianist, in training to play Chopin’s “Minute Waltz” in less than 60

ID: 3829936 • Letter: A

Question

An amateur pianist, in training to play Chopin’s “Minute Waltz” in less than   60 seconds practices the piece between 25 and 40 times at a sitting. The following code is a method that reads in first the number of times practicing, and a list of the times in seconds it takes the pianist to play the piece and prints out as output the time for the last 10 performances of the waltz followed by the average time for these 10 performances.

public static void main()

{

    int [ ] practice = new int[40];

    int times;

    int sum;

    double average;

    System.out.println( “How many times did you practice?”);

    Scanner keyboard = new Scanner ( System.in));

     __________________

     __________________

    

    for (__________________________

    {

        System.out.println( “Enter seconds for try “ + (i + 1) );

         ____________________________= keyboard.nextInt();

              }

    

     // averaging the last 10 tries

     sum = 0;

     for (

        ____________________________________

    ______________________________

    System.out.println ( “The average for the last 10 tries is “ + ____________);    

}

Explanation / Answer

PianistPracticing.java

import java.util.Scanner;

public class PianistPracticing {

   public static void main(String args[])
   {
   int [ ] practice = new int[40];
   int times;
   int sum;
   double average;
   System.out.println( "How many times did you practice?");
   Scanner keyboard = new Scanner ( System.in);
   times=keyboard.nextInt();
     
  
   for (int i=0;i<times;i++)
   {
   System.out.println( "Enter seconds for try " + (i + 1) );
   practice[i]= keyboard.nextInt();
   }
  
   // averaging the last 10 tries
   sum = 0;
     
   System.out.print("Displaying the last 10 Transactions :");
   for (int i=times-10;i<times;i++)
   {
       System.out.print(practice[i]+" ");
   sum+=practice[i];      
   }
     
   System.out.println ( " The average for the last 10 tries is " +(double)(sum/times));
   }
}

_____________________

Output:

How many times did you practice?
26
Enter seconds for try 1
56
5Enter seconds for try 2
7
Enter seconds for try 3
58
Enter seconds for try 4
59
Enter seconds for try 5
54
Enter seconds for try 6
53
Enter seconds for try 7
52
Enter seconds for try 8
54
Enter seconds for try 9
56
Enter seconds for try 10
57
Enter seconds for try 11
59
Enter seconds for try 12
56
Enter seconds for try 13
55
Enter seconds for try 14
56
Enter seconds for try 15
54
Enter seconds for try 16
53
Enter seconds for try 17
51
Enter seconds for try 18
45
Enter seconds for try 19
46
Enter seconds for try 20
48
Enter seconds for try 21
50
Enter seconds for try 22
54
Enter seconds for try 23
54
Enter seconds for try 24
53
Enter seconds for try 25
52
Enter seconds for try 26
51

Displaying the last 10 Transactions :51 45 46 48 50 54 54 53 52 51

The average for the last 10 tries is 19.0

__________________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote