import java.util.*;
import static java.lang.System.*;

public class LoopsLab {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        
        int number = 0;
        boolean go = true;

        while(go) {
            System.out.println("What do you want me to do?");

            System.out.println("1) | Display numbers: 1, 2, 3, 4, .., n");
            System.out.println("2) | Find sumation (sigma) of 1 + 2 + 3 + 4 + .. + n");
            System.out.println("3) | Find the product of n! = n * (n - 1) * (n - 2) * .. * 2 * 1. - factorial");
            System.out.println("4) | Find the product of x^y");
            System.out.println("0) | End Program");

            System.out.print("Option: ");
                int choice = reader.nextInt();

            System.out.println(" ");

            switch(choice) {
                case 0: System.out.println("Goodbye!");
                    go = false;
                    break;

                case 1: System.out.println("Display numbers up to");
                    number = reader.nextInt();
                    DisplayNumbers(number);
                    break;

                default: System.out.println(choice + " is NOT a valid choice!");
                    System.out.println();
            } // Switch
        } // While loop
    } // End

    public static void DisplayNumbers(int limit) {
        int x = 1;

        while(x <= limit) {
            System.out.print(x + ", ");
            x++;
        }

        System.out.println();
    }
    
    public static int Sigma(int target) {
        int total = 0;
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: