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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:25:34+00:00 2026-05-27T03:25:34+00:00

I get this error: ——————–Configuration: <Default>——————– C:\Documents and Settings\800508\Desktop\Chpt 8\Labs08\Lab08MATH02\Lab08MATH02st.java:20: ‘void’ type not allowed

  • 0

I get this error:

--------------------Configuration: <Default>--------------------
C:\Documents and Settings\800508\Desktop\Chpt 8\Labs08\Lab08MATH02\Lab08MATH02st.java:20: 'void' type not allowed here
    JOptionPane.showMessageDialog(null,r.getRational() + " equals " + r.getDec() + " and reduces to " + r.reduce());
                                                                                 ^

From this code:

// Lab08MATH02st.java
// The Rational Class Program I
// This is the student, starting version of the Lab08MATH02 assignment.


import javax.swing.JOptionPane;


public class Lab08MATH02st
{
    public static void main (String args[])
    {   
    String strNbr1 = JOptionPane.showInputDialog("Enter Numerator 1");
    String strNbr2 = JOptionPane.showInputDialog("Enter Denominator 2");

    int num = Integer.parseInt(strNbr1);
    int den = Integer.parseInt(strNbr2);

    Rational r = new Rational(num,den);
    JOptionPane.showMessageDialog(null,r.getRational() + " equals " + r.getDec() + " and reduces to " + r.reduce());

    System.exit(0); 
    }
}



class Rational
{

int num;
int den;
int n1;
int n2;
int gcf; 

public Rational(int n, int d)
{
num = n;
den = d;
}


//  Rational

//  getNum

//  getDen

//  getDecimal
    public double getDec()
    {
        return (double)num/den;
    } 
//  getRational 
    public String getRational()
    {
        return num + "/" + den;
    } 
//  getOriginal

//  reduce
    public void reduce()
    {
    num = num / 2;
    den = den / 2;
    }



    private int getGCF(int n1,int n2)
    {
        int rem = 0;
        int gcf = 0;
        do
        {
            rem = n1 % n2;
            if (rem == 0)
                gcf = n2;
            else
            {
                n1 = n2;
                n2 = rem;
            }
        }
        while (rem != 0);
        return gcf;
        } 
}

What’s the problem?

  • 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-27T03:25:34+00:00Added an answer on May 27, 2026 at 3:25 am

    The function reduce has void return type. And void cannot be appended to a String

    The function must return some value that can be represented as a String in order to append it to a string. If you return void the compiler and the runtime environment don’t know what to append to the string.

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

Sidebar

Related Questions

I get this error in view, when I have set the default locale to
I get this error message: Parse error: syntax error, unexpected $end in C:\Users\Stacky\Desktop\xampp\htdocs\wweff\stackhelp.php on
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within
I get this error when I do an svn update : Working copy XXXXXXXX
I get this error:- You have an error in your SQL syntax; check the
We get this error in Visual Studio 2005 and TFS very often. Can anyone
i get this error {Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL.}
I get this error message when installing SQL 2005 Analysis services. The cabinet File
I get this error: System.Reflection.TargetException: Object does not match target type. when trying to

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.