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

1. Write a set of instructions which will prompt the user and input 3 int values

ID: 3879574 • Letter: 1

Question

1. Write a set of instructions which will prompt the user and input 3 int values, compute the average and output the result as a double, formatted so that exactly 1 digit appears to the right of the decimal point. Assume that Scanner and DecimalFormat classes have already been imported. 2. Write a "query-controlled" while loop (it asks the user if he wants to continue or not) that inputs int values from the user, adding each to the int value sum, and then ask if he has another value to input, until the user says there are no more values. Assume that Scanner class has already been imported.
3. Write a method that is passed the int value of the number of hours worked for the week as a parameter, and returns the pay for the employee (including overtime, which is 1.5 * hourly wages for each hour over 40).
4. Write a set of code to create a two-dimensional array and initialize every element to be the value of i*j where i and j are the two indices (for instance, element [5][3] is 5*3 = 15.
5. Write a method called reverse that accepts a string parameter and returns a string made up of characters of the parameters in reverse order. There is a method in the String class that performs this operation, but for this test, you should write your own.
These are practice problems to refresh my memory of what I have learned can you please solve these in java please thank you very much. 1. Write a set of instructions which will prompt the user and input 3 int values, compute the average and output the result as a double, formatted so that exactly 1 digit appears to the right of the decimal point. Assume that Scanner and DecimalFormat classes have already been imported. 2. Write a "query-controlled" while loop (it asks the user if he wants to continue or not) that inputs int values from the user, adding each to the int value sum, and then ask if he has another value to input, until the user says there are no more values. Assume that Scanner class has already been imported.
3. Write a method that is passed the int value of the number of hours worked for the week as a parameter, and returns the pay for the employee (including overtime, which is 1.5 * hourly wages for each hour over 40).
4. Write a set of code to create a two-dimensional array and initialize every element to be the value of i*j where i and j are the two indices (for instance, element [5][3] is 5*3 = 15.
5. Write a method called reverse that accepts a string parameter and returns a string made up of characters of the parameters in reverse order. There is a method in the String class that performs this operation, but for this test, you should write your own.
These are practice problems to refresh my memory of what I have learned can you please solve these in java please thank you very much. 2. Write a "query-controlled" while loop (it asks the user if he wants to continue or not) that inputs int values from the user, adding each to the int value sum, and then ask if he has another value to input, until the user says there are no more values. Assume that Scanner class has already been imported.
3. Write a method that is passed the int value of the number of hours worked for the week as a parameter, and returns the pay for the employee (including overtime, which is 1.5 * hourly wages for each hour over 40).
4. Write a set of code to create a two-dimensional array and initialize every element to be the value of i*j where i and j are the two indices (for instance, element [5][3] is 5*3 = 15.
5. Write a method called reverse that accepts a string parameter and returns a string made up of characters of the parameters in reverse order. There is a method in the String class that performs this operation, but for this test, you should write your own.
These are practice problems to refresh my memory of what I have learned can you please solve these in java please thank you very much.

Explanation / Answer

1.    Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      double sum = a + b + c;
      double avg = sum/3.0;
      DecimalFormat df = new DecimalFormat("#.#");
      System.out.println(df.format(avg));


2.   
      sum = 0;
      while (true){
          System.out.println("Enter a number:");
          int a = sc.nextInt();
          sum = sum + a;
          System.out.println("Do you want to continue (yes/no):");
          string str = sc.next();
          if (str.equals("no"))
             break;
      }

3.   
      hourlyWage is defined as a constant or class member

      double calculatePay(int hr){
           if (hr <= 40){
              return hr*hourlyWage;
           }
           else {
               double diff = hr - 40;
               return (40 * hourlyWage + diff * (1.5 * hourlyWage));
           }         
      }

4.    int A[][] = new int[5][5];

      for (int i = 0; i<5; i++){
        for(int j = 0; j<5; j++){
             A[i][j] = i*j;
        }
      }
5    
      String reverse(String str){

         if (str == null){
             return null;
         }
         if (str.length() == 1){
             return str;
         }
         string res="";
         for (int i = str.length()-1; i>=0; i--){
            res = res + str.charAt(i);
         }
         return res;
      }