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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:44:29+00:00 2026-06-16T07:44:29+00:00

I have created a Java class called Rectangle that has the two instance variables

  • 0

I have created a Java class called Rectangle that has the two instance variables (width & height) &
two instance methods (area and circumference) both method do not take parameters but
return double values. The area method returns area of rectangle (width * height) while
circumference returns (2*width+2*height). Then create Demo class with main method to test
the class Rectangle by instantiating 4 objects and prompts user to enter width and height for
each instance. Then print out the area and circumference for each instance.

I create two class and the first class is Rectangle :

public class Rectagle {

    private double width;
    private double height;

    public double area() {
        return width * height;
    }

    public double circumference() {
        return 2*width+2*height;
    }
}

and I create the second class Demo to Test the class :

import java.util.Scanner;
public class Demo {
    public static void main(String []args){
        Scanner console=new Scanner(System.in);
    Rectagle R1=new Rectagle();
    Rectagle R2=new Rectagle();
    Rectagle R3=new Rectagle();
    Rectagle R4=new Rectagle();

    }
}

my problem , I don’t understand this point ” and prompts user to enter width and height for
each instance. Then print out the area and circumference for each instance.

  • 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-16T07:44:30+00:00Added an answer on June 16, 2026 at 7:44 am

    May this help you

    public class Rectangle {
    
        private double width;
        private double height;
    
        public Rectangle(double width, double height) {
            this.width = width;
            this.height = height;
        }
    
        public double getArea() {
            return width * height;
        }
    
        public double getCircumference() {
            return 2*width+2*height;
        }
    
        @Override
        public String toString() {
            return "Rectangle["+width+","+height+"]Area:"+getArea()+",Circumference:"+getCircumference();
        }
    
        public static void main(String[] args) {
             Scanner console=new Scanner(System.in);
            double width = getValue(console, "Width");
            double height = getValue(console, "Height");
            Rectangle rectangle = new Rectangle(width, height);
            System.out.println(rectangle);
    
        }
    
        public static double getValue(Scanner console, String name) {
            System.out.println("Enter "+name + " : ");
            String widthStr = console.nextLine();
            double parseDouble;
            try {
                parseDouble = Double.parseDouble(widthStr);
            }catch(NumberFormatException ne) {
                System.out.println("Unable to parse your input, enter correct value ");
                return getValue(console, name);
            }
            return parseDouble;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Java, I have created a class called Writer that extends It is initialized
I have this java method in class called IntArray. The class has methods to
Working on my assignment for Java and I have created a class called Triangle.
I have created a new class called Get_WebPage1 and init I have extends that
I have certificate created using java class CertAndKeyGen and X500Name and I am able
In Java I have created the following class which extends ImageView to create a
I have created a java application for Debian Linux. Now I want that that
I have created a class called Placeslist when i try to make a list
I have created a class called SimpleCanvas which extends the JPanel class, and I
I have created a simple Java class as follows: I pass content as a

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.