Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:23:00+00:00 2026-05-28T08:23:00+00:00

— I am to write a program that prompts for N which is number

  • 0

— I am to write a program that prompts for N which is number of dice to roll and M for number of times to roll. I must repeat M times N6 or six sided die and compute and record the total sum of rolls. Using an array i must report how many times along with a percentage each possible total from 6 to 6N occurred.

Here is my code so far, i cannot get it to compile, and i think im going about it completely wrong, we only have one professor that teaches java, and he is not good at explaining things and always seems to be in a hurry if we ask questions. This is my second division class, and i learned barely anything the first semester.
////////////////////////////////

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

     public class Lab1
    {
   public static Scanner in = new Scanner (System.in);
       public static void main (String[] args)

{
      int dice = 0;
        int roll = 0;
       while (true) 
     {
      System.out.print ("How many dice do you roll?");
            dice = in.nextInt();
       }


         System.out.print ("How many Times do you want to roll?");
           roll = in.nextInt();
           }
         int dicetotal = Dicecount (dice); //Error message. dice cannot be resolved to Variable//
         for (int i = 0; i< roll; i++)

         System.out.println (Dicecount (dice));
          }
       }
       public static int Dicecount ( int dice); 
         {
        int dicetotal = 0;
        for (int x = 0: x < dice; x++)
      {
         int rollcount = (int) (1+6* (Math.random()));
       dicetotal+=rollcount;}
     return dicetotal;
     }
      }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:23:01+00:00Added an answer on May 28, 2026 at 8:23 am

    Properly format your code. This will help you find that the 6 lines starting with:

    int dicetotal = Dicecount (dice);
    

    Are not within a function block, and need to be.

    You also have a colon instead of a semi-colon in this line (~7th from the bottom):

    for(int x = 0; x < dice; x++){
    

    Fixing these errors will allow your code to successfully compile – but that doesn’t mean that it will do what you want it to do. Since this is homework, you’ll be expected to find these issues and at least do initial troubleshooting on them yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, is there a way to write a.children('.outer').children('.inner') without the intermediate selector? I can't
I recently ran against a very interesting site that expresses a very interesting idea
I am looking for a way to format a floating point number dynamically in
&mdash; or &#8212; Is there a difference between these? Is one better-supported than the
What is the absolute fastest way to read and write strings from a file
I'm using a DatePicker ( org.apache.wicket.extensions.yui.calendar.DatePicker — Javadoc ) in a form. The form
I have a fairly mundane piece jQuery that toggles a div's visibility when a
I'm having a simple problem toggling between +/- characters which prepend a link which
I'm including a local class that requests a file from a remote server. This
I'm trying to create a parser (with parsec), that parses tokens, delimited by newlines,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.