Remix: Make a Simple Program

For this remix, I decided to build off of my computer program I did the first week of this class.

The remix instructs to do the opposite of what the instruction says. Check out my simple program here! To remix, I decided to do a program that requires user input to determine how many dice need to be rolled. The, the program will output what each dice rolled and output the total of the dice. The program continuous to run until the user tells the program to quit.

Check out the code below:

package com.company;
import java.util.Random;
import java.util.Scanner;

public class DS106 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Random numGenerator = new Random();
        System.out.println("How many dice will you need?");
        int numDice = in.nextInt();
        System.out.println("Would you like to roll the dice? respond: yes or no");
        String response = in.next();
        while (response.equalsIgnoreCase("yes")) {
            int totalNumber = 0;
            for (int i = 0; i < numDice; i++) {
                int number = numGenerator.nextInt(6) + 1;
                totalNumber = number + totalNumber;
                if (number != 0) {
                    System.out.println("The die is a " + number + ".");
                }
            }
            System.out.println();
            System.out.println("The total number from the dice is " + totalNumber + ".");
            System.out.println();
            System.out.println("Would you like to roll the dice?");
            response = in.next();
            System.out.println();
        }
        System.out.println();
        System.out.println("Thank you for using the virtual dice.");
    }
}



Check out an example run!