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

Please use Java (not Javascript) to complete the following codes already given:

ID: 3664373 • Letter: P

Question

Please use Java (not Javascript) to complete the following codes already given:

1.

2.

3.

Write a for loop to print all NUM-VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp = 90, 92, 94, 95), print 90, 92, 94, 95 Note that the last element is not followed by a comma, space, or newline import java.util.Scanner; 3 public class PrintwithComma f 4 public static void main (String ] args) t final int NUM VALS = 4; int [ ] hourlyTemp = new int [ NUM VALS]; int i-0; 6 9 hourlyTemp [0] hourlyTemp[1] hourlyTemp[2] hourlyTemp [3] = 90; 92; 94; 95; 12 13 15 16 17 18 Your solution goes here / System.out.println(" return; Run

Explanation / Answer

1.

public class PrintWithComma {
   public static void main(String[] args){
       final int NUM_VALS=4;
       int[] hourlyTemp=new int[NUM_VALS];
       int i=0;
      
       hourlyTemp[0]=90;
       hourlyTemp[1]=92;
       hourlyTemp[2]=94;
       hourlyTemp[3]=95;
      
       for(i=0;i<NUM_VALS;i++){
           if(i!=NUM_VALS-1){
               System.out.print(hourlyTemp[i]+", ");
           }else{
               System.out.print(hourlyTemp[i]);
           }
       }
       System.out.println("");
   }
}

2.

package project1;

public class PrintItemList {
   public static void main(String[] args){
       int[] keyList=new int[4];
       int[] itemList=new int[4];
       int i=0;
      
       keyList[0]=42;
       keyList[1]=105;
       keyList[2]=101;
       keyList[3]=100;
      
       itemList[0]=10;
       itemList[1]=20;
       itemList[2]=30;
       itemList[3]=40;
       for(i=0;i<4;i++){
           if(keyList[i]>100){
               System.out.print(itemList[i]+" ");
           }
       }
   }
}

3.

public class StudentScores {
   public static void main(String[] args){
       final int SCORES_SIZE=4;
       int[] oldScores=new int[SCORES_SIZE];
       int[] newScores=new int[SCORES_SIZE];
       int i=0;

       oldScores[0]=10;
       oldScores[1]=20;
       oldScores[2]=30;
       oldScores[3]=40;
      
       int temp=oldScores[0];
       for(i=0;i<SCORES_SIZE-1;i++){
           newScores[i]=oldScores[i+1];
       }
       newScores[i]=temp;
      
       for(i=0;i<SCORES_SIZE;++i){
           System.out.print(newScores[i]+" ");
       }
       System.out.println();
   }
}