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 8508881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:17:01+00:00 2026-06-11T03:17:01+00:00

Alright, I am trying to write this code but I keep getting this stupid

  • 0

Alright, I am trying to write this code but I keep getting this stupid error. I have no idea what I am doing wrong so maybe one of you experts can help me out.

import java.util.*;

public class School
{
Random randQuest = new Random();

int userAnswer;

public void createQuestion()
{

    int range = 10; // range of numbers in question

    int num1 = randQuest.nextInt( range );
    int num2 = randQuest.nextInt( range );

    userAnswer = num1 * num2;

    System.out.printf( "How much is %d times %d?\n",
        num1, num2 );

}

// prompt comment
public String promComm( boolean answer )
{
    if ( answer )
    {
        switch ( randQuest.nextInt( 1 ) )
        {

        case 0:
            return( "Very Good!" );

        }

        switch ( randQuest.nextInt( 1 ) )
        {

        case 0:                 
            return( "No. Please try again." );

        }
    }
}

}

  • 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-06-11T03:17:03+00:00Added an answer on June 11, 2026 at 3:17 am

    In method promComm if answer is false the method does not return any value.
    Same if randQuest.nextInt(1) != 0.

    Should be something like :

    public String promComm( boolean answer ){
        if (answer){
    
            switch (randQuest.nextInt(1)){    
               case 0:
                   return("Very Good!");
            }
    
            switch (randQuest.nextInt(1) ){
               case 0:                 
                   return( "No. Please try again." );
            }
    
            return "Some value";
    
        }else
    
            return "Some value";
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, here I am again trying to write code from scratch and I can't
Alright so I'm trying to embed an swf file with this code: <object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000
Alright, I'm trying to write some code that removes words that contain an apostrophe
Alright... I'm trying to write some javascript code that will apply to an html
Alright so I'm trying to get captcha to work here and I have this
Alright so I have been trying to get all of my separate classes (At
Alright, so I'm trying to achieve whats in this image: I believe this would
Alright, I'm just trying to learn about using Contact information, but I'm a bit
Alright, so here's my problem. I'm trying to write a script in PHP that
Hii , I have been trying to write a program... We have a structure

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.