I need help fixing my java code so that its output should compute a random number of "*" not numbers:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help fixing my java code so that its output should compute a random number of "*" not numbers:

Like the image given not this output below: 

dice number 1: 2
dice number 2: 1
dice number 3: 1
dice number 4: 0
dice number 5: 1
dice number 6: 0

Java code: 

import java.util.*;
public class PrintRandomChart_Class_FallProject_1
{
public static void main(String[] args) {
    
     System.out.println("This game requests a number from the player.");
      System.out.println("The game then throws the dice that number of times.");
      System.out.println("The game then displays a chart showing the number of ");
      System.out.println("times the six dice faces appeared given");
      System.out.println("the number of throws.");
      System.out.println("Please enter the number of times that you would");
      System.out.println("like the computer to throw the dice.");

Scanner sc= new Scanner(System.in); 
int[] a = new int[6];  
char c;
int diceFaceNumber;
    do{
       int n= sc.nextInt(); 
    for(int i=0;i<6;i++){
    a[i]=0;
    }
    for(int i=0;i<n;i++){
    diceFaceNumber = (int)(Math.random() * 6) + 1;
    int k=diceFaceNumber-1;
    a[k]=a[k] + 1;
    }
    for(int i=0;i<6;i++){

    System.out.println("dice number "+(i+1)+": "+a[i]);
    }
    System.out.print("Do you want to continue(Y/N): ");
       c= sc.next().charAt(0); 
      System.out.println("Please enter the number of times that you would");
       System.out.println("like the computer to throw the dice.");

    }while(c!='N');
}
}
      
   

100
yes
like the computer to throw the dice.
A chart of 100 throws.
dice number 1: *******************
dice number 2: *************************
dice number 3: ***********
dice number 4: **********
dice number 5: ******************
dice number 6: *****************
Would you like to play the game again?
Please enter (yes/no)
Please enter the number of times that you would
like the computer to throw the dice.
Transcribed Image Text:100 yes like the computer to throw the dice. A chart of 100 throws. dice number 1: ******************* dice number 2: ************************* dice number 3: *********** dice number 4: ********** dice number 5: ****************** dice number 6: ***************** Would you like to play the game again? Please enter (yes/no) Please enter the number of times that you would like the computer to throw the dice.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Hiring Problem
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education