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

Write a program in java that creates a String array with the values \"Winter\",

ID: 3827318 • Letter: W

Question

Write a program in java that creates a String array with the values "Winter", "Spring", "Summer", "Fall". Using an appropriate prompt, input from the keyboard (data validation IS required) a value between 1 and 4 with 1 to indicate "Winter", 2 to indicate "Spring", 3 to indicate "Summer", and 4 to indicate "Fall" . Use this value in a CASE statement to print the name of the requested season. (Remember that subscripts for arrays start at 0, not 1). I need this code in 12 minutes need to put turn this in class.

Explanation / Answer

import java.util.*;

import java.lang.*;

import java.io.*;

class Ideone
{
  
   public static void main (String[] args)
   {
       String[] seasonString = new String[10];
       seasonString[2] = "Winter";
       seasonString[3] = "Spring";
       seasonString[4] = "Summer";
       seasonString[5] = "Fall";
      
       Scanner scan = new Scanner(System.in);
       System.out.println("Enter a number: ");
       int i = scan.nextInt();

       switch(i)
       {
           case 1: System.out.println(seasonString[2]);
               break;
           case 2: System.out.println(seasonString[3]);
               break;
           case 3: System.out.println(seasonString[4]);
               break;
           case 4: System.out.println(seasonString[5]);
               break;
           default:
               System.out.println("Please enter correct value btw 1 to 4");
               break;
       }
   }
}

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