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

Please use java for this. Assignment Description: Checkpoints Yous MUST use arra

ID: 3825171 • Letter: P

Question

Please use java for this.

Assignment Description: Checkpoints

Yous MUST use arrays(or arraylist) for this exercise.

Write a program that does the following:

• (1 Point) Provide the following “menu” (choices) to the user:

o Enter Checkpoints

o Edit Checkpoints

o Display Checkpoints

o Exit program

• Ask the user to choose from the menu

o (2 Points) Continue to show the menu (even with invalid choice – give error message but don’t exit) until the user chooses “Exit program.”

• For “Enter Checkpoints”:

o (1 Point) Ask the user for data to store for the given checkpoint

(1 Point) Keep track of how many checkpoints has been entered and tell the user what # checkpoint they are to enter.

(1 Point) Store data for each checkpoint in an appropriate array.

o Ask the user if the user would like to enter more checkpoints

(1 Point) Allow the user to keep entering data until the user says otherwise

o (1 Point) Return to the menu when the user is done entering trip data

• For “Edit Checkpoints”:

o (1 Point) Ask the user for which checkpoint to edit (tell the user how many checkpoints are available)

(1 Point) Show the user the data for the checkpoint to edit and ask the user for a replacement data.

o Ask the user if the user would like to edit more checkpoints

(1 Point) Allow the user to keep editing data until the user says otherwise

o (1 Point) Return to the menu when the user is done editing checkpoints

• For “Display Checkpoints”

o (2 Points) Display every data for each checkpoint

o (1 Point) Return to the menu after displaying data for each checkpoint

Explanation / Answer

The below code will satisfy the required functionalities which are discussed in the question:-


package chegg;

import java.util.ArrayList;

public class Checkpoints {

public static void main(String[] args) {
     
   ArrayList <String> Checkpoints = new ArrayList<String>()
   Scanner sc= new Scanner(System.in);
   do
   {
   String Exit="F";
   System.out.print("Ener any number in the following list : (1) Enter Checkpoints (2) Edit Checkpoints (3)Display Checkpoints (4) Exit program")
   int choice=sc.nextInt();
   swith(choice)
   {
       case 1:     
           do
           {                 
               System.out.print("enter data to add in to check point");
               String s=sc.next();
               Checkpoints.add("s");
           System.out.print("check point added succesfully would you like to add more? y/n");
               String temp=sc.next();
           }while(temp=="y")
       break;
       case 2:     
           do
           {             
               System.out.print("enter position to edit the check point");
               int n=sc.nextInt();
               System.out.print("enter data to update in the check point");
               String s=sc.next();
               Checkpoints.set(n,"s");
           System.out.print("check point edited succesfully would you like to edit more? y/n");
               String temp=sc.next();
           }while(temp=="y")
       break;
       case 3:     
           do
           {             
               for(int i = 0; i < Checkpoints.size(); i++)
                   {
                       System.out.print("The checkpoints are:-");
                       Checkpoints c = Checkpoints.get(i);
                       {
                           System.out.print(c.get (i)+" ");
                       }
                   }
           }while(temp=="y")
       break;
       case 4:
           Exit="T";
           break;
         
   }
   }while(Exit=="F");

   }

}