Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Netbeans Java Design a UML class diagram for the leading class. Design a pseudoc

ID: 3786091 • Letter: N

Question

Netbeans Java

Design a UML class diagram for the leading class.

Design a pseudocode algorithm for any method that will have two or more statements.

Design a pseudocode algorithm for the test class .

Apply JLCs for naming the class, the variables, and the method

Write a Java program that can be used to find the area and perimeter of a rectangle. In designing your program, given consideration to the following:

Write a class called Measurement with the following features:

Member variables – length, width, area, and perimeter.

Constructor that accepts the length and width of each rectangle.

Instance mutator method calculates that computes the area and the perimeter of a rectangle.

Instance mutator methods, one to change length, and the other to change the width.

Accessor methods that returns the value of each variable.

There doesn't need to be a test class

Explanation / Answer


import java.util.*;
public class measurementmain {
   public static void main(String[] args) {
       // TODO Auto-generated method stub
      
       Scanner sc=new Scanner(System.in);
       int len=0;
       int wid=0;
       while(true){
           System.out.println("enter length:");
           len=sc.nextInt();
           System.out.println("enter breadth:");
           wid=sc.nextInt();
          
       measurement m=new measurement(len,wid);
       System.out.println("enter choice:");
       System.out.println("1.perimeter 2.area 3.quit");
       int ch=sc.nextInt();
       switch(ch){
       case 1:int p=m.findperimeter();
       //System.out.println("perimeter is:"+p);
       break;
       case 2:int ar=m.findarea();
       //.out.println("area is:"+ar);
       break;
       case 3:System.exit(0);
      
       }
       }
   }
}


measurement.java:
public class measurement {
   int length;
   int width;
   int perimeter;
   int area;
   measurement(int length,int width){
setlength(length);
setwidth(width);

   }
   private void setwidth(int width) {
       this.width=width;
       System.out.println(width);
      
   }
   private void setlength(int length) {
       // TODO Auto-generated method stub
       this.length=length;
       System.out.println(length);
   }
   public int getlength(){
       return length;
   }
   public int getwidth(){
       return width;
   }
   public int findperimeter(){
       perimeter=2*(length+width);
       System.out.println("perimeter is:"+perimeter);
       return perimeter;
   }
   public int findarea(){
       area=length*width;
       System.out.println("area is:"+area);
       return area;
   }
}

output:
enter length:
2
enter breadth:
3
2
3
enter choice:
1.perimeter
2.area
3.quit
1
perimeter is:10
enter length:
2
enter breadth:
3
2
3
enter choice:
1.perimeter
2.area
3.quit
2
area is:6
enter length:
3
enter breadth:
1
3
1
enter choice:
1.perimeter
2.area
3.quit
3

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote