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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:03:12+00:00 2026-05-27T17:03:12+00:00

Ok, so I know this is a noob question but I am having trouble

  • 0

Ok, so I know this is a noob question but I am having trouble getting this code to work. What the code is supposed to do is give you the diamter when you input the radius. I know my code is probably butchered but what am I doing wrong and why because I am trying to learn.

import java.util.Scanner;

public class Circle{

Scanner dd = new Scanner(ystem.in);

System.out.println("Whats is the radius?");
double r = dd.nextDouble();

public Circle(double r){

    radius = r;
}

public double diameter(){

    double d = radius * 2;
    return d;
}
}

public class Tester{

public static void main(String args[]){

    Circle cir1 = new Circle(35.5);
    System.out.println(Circle.diameter)
}
}
  • 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-27T17:03:13+00:00Added an answer on May 27, 2026 at 5:03 pm

    You must put you code in a method. This block will cause an error :

    Scanner dd = new Scanner(System.in);
    
    System.out.println("Whats is the radius?");
    double r = dd.nextDouble();
    

    Next, in your main, you do Circle cirl = new Circle(35.5) and on the next line, you call Circle.diameter. You should call the diameter from you new instance as so cirl.diameter().

    You could try something like this instead

    import java.util.Scanner;
    
    public class Circle{
    
        private double radius;
    
        public Circle(double r){
    
            radius = r;
        }
    
        public double diameter(){
    
            double d = radius * 2;
            return d;
        }
    
        public static void main(String args[]){
    
            Scanner dd = new Scanner(System.in);
    
            System.out.println("Whats is the radius?");
            double r = dd.nextDouble();
            Circle cir1 = new Circle(r);
            System.out.println(cir1.diameter())
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I know this is a Noob question but I cant see to get
I appreciate this is an incredibly noob question, but having Googled multiple combinations of
I realize this is a painfully noob question but I just don't know what
I know this is a noob question, but I've worked with Python before and
Not sure how noob or advanced this question is, but I've been having kind
I know this is a noob question but ...I have these labels on a
although this question sound noob.. but i really need to know this. What is
although this question sound noob.. but i really need to know this. What is
This is a noob question, I know but I didn't find the answer on
I know this is a noob-ish question but is it possible to fully center

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.