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

write a program that creates a two dimensional array to save the week days. Then

ID: 3582764 • Letter: W

Question

write a program that creates a two dimensional array to save the week days. Then ask the user to enter a number between 0 and 6. The program should print the corresponding day. write a program that creates a two dimensional array to save the week days. Then ask the user to enter a number between 0 and 6. The program should print the corresponding day. write a program that creates a two dimensional array to save the week days. Then ask the user to enter a number between 0 and 6. The program should print the corresponding day.

Explanation / Answer

Note : Cold you please check, is this is the required output? .If youw want to modify I will do it.Thank You

__________________________

TwoDimArray.java

import java.util.Scanner;

public class TwoDimArray {

   public static void main(String[] args) {
       //Declaring variables
       int number;
       String day = null;
      
       //Declaring and initializing two dimensional array
       String weekDays[][]={{"0","Monday"},
               {"1","Tuesday"},
               {"2","Wednesday"},
               {"3","Thursday"},
               {"4","Friday"},
               {"5","Saturday"},
               {"6","Sunday"}};
      
       //Scanner class object is used to read the inputs entered by the user
       Scanner sc=new Scanner(System.in);
      
       //Getting the number entered by the user
       System.out.print("Enter the number between 0 and 6 :");
       number=sc.nextInt();
      
       //This for loop will find the corresponding day
for(int i=0;i<weekDays.length;i++)
{
       if(number==Integer.parseInt(weekDays[i][0]))
       {
           day=weekDays[i][1];
       }
}
  
//Displaying the day of the week
   System.out.println("The Corresponding day is :"+day);
}
  

   }

______________________

output:

Enter the number between 0 and 6 :4
The Corresponding day is :Friday

_________Thank You