Question & Answer: Java Write a program…..

Java

Write a program

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Java Write a program…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

There are four types (Type 1, 2, 3, 4) For each type you get two options 1) Roll a die with 20 sides, ranging from 1 to 20. 2) Choose 10. Your task is to change the lowest type’s value to 20.

Expert Answer

 

import java.util.Random;
import java.util.Scanner;

public class Rolling {

public static void main(String[] args) {
// TODO Auto-generated method stub
int type;
System.out.println(“Enter the type (1/2/3/4)”);
Scanner sc = new Scanner(System.in);
type = sc.nextInt();

Random random = new Random();
int n = random.nextInt(20) + 1;

System.out.println(“you rolled a dice with faces (1-20), you got “+n);

System.out.println(“You have chosen 10”);

}

}

============================================
See Output

Question & Answer: Java Write a program..... 1

Still stressed from student homework?
Get quality assistance from academic writers!