Session 28
Source Code
import java.util.*;
public class Session28 {
public static void main(String[] args) {
System.out.println("Session 28");
// Menu
System.out.println("Menu");
System.out.println("E1 - Example 1");
// setup Scanner
Scanner in = new Scanner(System.in);
System.out.print("Choice: ");
String choice = in.nextLine();
// switch choices
switch (choice) {
case "E1":
System.out.println("Example 1");
example1();
break;
case "E2":
System.out.println("Example 2");
example2();
break;
case "E3":
System.out.println("Example 3");
example3();
break;
default:
System.out.println("Invalid choice");
}
}
// example1 method
public static void example1() {
// declares an array of integers
// create an empty array of size 3
// print the values in the scores array
// declare and create an array of doubles
// assign values to each index position
// print the values in the prices array
}
// example2 method
public static void example2() {
// declare an array of String elements
// assign values to each index position
// print the values in the friends array
}
// example3 method
public static void example3() {
// create an array with an initializer list
// .length property
}
}S28Problem1.java
S28Problem2.java
S28Problem3.java
Last updated
Was this helpful?