Question
Can someone paraphrase this code for plagiarism reasons. package wk1javabasics; import java.util.*; public class Main { static String name ; static int t ; public
Can someone paraphrase this code for plagiarism reasons.
package wk1javabasics;
import java.util.*;
public class Main
{
static String name;
static int t;
public static void main(String[] args) {
System.out.print("Welcome to the Java Dice Game, Lock N Roll! "
+ "The object of the game is to roll 3 dice and earn the most points. "
+ "Player earns points by maximizing the sum of the dice and earning bonus points. "
+ "Bonus points are earned when rolling a pair, triples, or a straight: "
+ " o Pair Bonus: 2 points "
+ " o Triple Bonus: 30 points "
+ " o Straight Bonus: 10 points "
+ "Player gets 2 rolls. After the first roll, player chooses to either "
+ "\"Lock\" or \"Roll\" a die again, for each of the 3 dice. "
+ "Scoring for the turn is complete after the second roll. "
+ " "
+ "Enter your name to begin this fast-action game, and let's LOCK N ROLL! ");
Scanner s=new Scanner(System.in);
System.out.println("Name:");
name=s.next();
System.out.println("How many turns would you like in this game?");
t=s.nextInt();
int[] Imprv=new int[t];
int[] array=new int[8*2*t];
Random rand = new Random();
for(int i=1;i<=t;i++){
System.out.println("************** Begin Turn "+i+"***************");
System.out.println("1 2 3 Sum Pair Trip Strait Points");
System.out.println("-- -- -- --- ---- ---- --- ---");
array[(8*(i-1))]=(rand.nextInt(6)+1);
array[(8*(i-1))+1]=(rand.nextInt(6)+1);
array[(8*(i-1))+2]=(rand.nextInt(6)+1);
array[(8*(i-1))+3]=array[(8*(i-1))]+array[(8*(i-1))+1]+array[(8*(i-1))+2];
if(array[(8*(i-1))]==array[(8*(i-1))+1]|| array[(8*(i-1))+1]==array[(8*(i-1))+2] || array[(8*(i-1))+2]==array[(8*(i-1))]){
array[(8*(i-1))+4]=2;
}
else if((array[(8*(i-1))]==array[(8*(i-1))+1] ) && (array[(8*(i-1))+1]==array[(8*(i-1))+2])){
array[(8*(i-1))+5]=30;
array[(8*(i-1))+4]=0;
}
if((array[(8*(i-1))]==(array[(8*(i-1))+1]-1)) && (array[(8*(i-1))+1]==(array[(8*(i-1))+2]-1))){
array[(8*(i-1))+6]=10;
}
array[(8*(i-1))+7]=array[(8*(i-1))+3]+array[(8*(i-1))+4]+array[(8*(i-1))+5]+array[(8*(i-1))+6];
System.out.println("Roll-"+1+" "+array[(8*(i-1))]+" "+array[(8*(i-1))+1]+" "+array[(8*(i-1))+2]+" "+array[(8*(i-1))+3]+" "+array[(8*(i-1))+4]+" "+array[(8*(i-1))+5]+" "+array[(8*(i-1))+6]+" "+array[(8*(i-1))+7]);
System.out.println("Now it's time to LOCK N ROLL!");
int count=0;
for(int j=1;j<=3;j++){
System.out.println("Die"+j+" value:"+array[(8*(i-1)+(j-1))]+" Enter l or r:");
String temp=s.next();
if(temp.trim().equals("r")){
if(j==1){
array[(8*i)]=(rand.nextInt(6))+1;
if(array[(8*i)+1]==0){
array[(8*i)+1]=array[(8*(i-1))+1];
}
if(array[(8*i)+2]==0){
array[(8*i)+2]=array[(8*(i-1))+2];
}
}
else if(j==2){
array[(8*i)+1]=(rand.nextInt(6))+1;
if(array[(8*i)]==0){
array[(8*i)]=array[(8*(i-1))];
}
if(array[(8*i)+2]==0){
array[(8*i)+2]=array[(8*(i-1))+2];
count=count+1;
}
else{
array[(8*i)+2]=(rand.nextInt(6))+1;
if(array[(8*i)+1]==0){
array[(8*i)+1]=array[(8*(i-1))+1];
}
if(array[(8*i)]==0){
array[(8*i)]=array[(8*(i-1))];
}
count=count+1;
}
}
}
array[(8*i)+3]=array[(8*i)]+array[(8*i)+1]+array[(8*i)+2];
if(array[(8*i)]==array[(8*i)+1] || array[(8*i)+1]==array[(8*i)+2] || array[(8*i)+2]==array[(8*i)]){
array[(8*i)+4]=2;
}
else if((array[(8*i)]==array[(8*i)+1]) && (array[(8*i)+1]==array[(8*i)+2])){
array[(8*i)+5]=30;
array[(8*i)+4]=0;
}
if((array[(8*i)]==(array[(8*i)+1]-1)) && (array[(8*i)+1]==(array[(8*i)+2]-1))){
array[(8*i)+6]=10;
}
array[(8*i)+7]=array[(8*i)+3]+array[(8*i)+4]+array[(8*i)+5]+array[(8*i)+6];
Imprv[i-1]= (array[(8*i)+7]-array[(8*(i-1))+7]);
System.out.println("Roll-"+2+" "+array[(8*i)]+" "+array[(8*i)+1]+" "+array[(8*i)+2]+" "+array[(8*i)+3]+" "+array[(8*i)+4]+" "+array[(8*i)+5]+" "+array[(8*i)+6]+" "+array[(8*i)+7]);
System.out.println(" --Roll1-- --Roll2-- Sum Pair Trip Strait Total Imprv");
System.out.println("-- -- -- -- -- -- --- ---- ---- ---- ---- ----");
System.out.print("Turn-"+i+" ");
for(int k=(2*8*(i-1));k<((2*8*(i-1))+16);k++){
System.out.print(array[k]+" ");
}
System.out.println(Imprv[i-1]);
}
System.out.println("**************************************************************");
System.out.println("Turn History for this session");
for(int i1=1;i1<=t;i1++){
System.out.print(name+"Turn-"+i1+":"+" ");
for(int k=(2*8*(i1-1));k<((2*8*(i1-1))+6);k++){
System.out.print(array[k]+" ");
}
System.out.print("Pts: "+array[8*(i1-1)+7]+" Imprv:"+Imprv[i1-1]);
System.out.println("");
}
System.out.print("Would you like to play again? Enter Y or N:");
String y_n=s.next();
System.out.println(y_n);
System.out.println("Thanks for playing, Come back and play again soon!");
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started