Question

Java Write a program to print the perimeter and area of rectangles using all combinations of...

Java

Write a program to print the perimeter and area of rectangles using all combinations of heights and widths running from 1 foot to 10 feet in increments of 1 foot. Print the output in headed, formatted columns.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class Main {
  public static int area(int i, int j){
    return i*j;
  }
  public static int perimeter(int i, int j){
    return 2*(i+j);
  }
  public static void main(String args[]){
    for(int height = 1;height<=10;height++){
      for(int width=1;width<=10;width++){
        System.out.println("Height = "+height+", Width = "+width+" Then area = "+area(height,width)+", perimeter = "+perimeter(height,width));
      }
    }
  }
}

Height = 1, Width = 1 Then area = 1, perimeter = 4
Height = 1, Width = 2 Then area = 2, perimeter = 6
Height = 1, Width = 3 Then area = 3, perimeter = 8
Height = 1, Width = 4 Then area = 4, perimeter = 10
Height = 1, Width = 5 Then area = 5, perimeter = 12
Height = 1, Width = 6 Then area = 6, perimeter = 14
Height = 1, Width = 7 Then area = 7, perimeter = 16
Height = 1, Width = 8 Then area = 8, perimeter = 18
Height = 1, Width = 9 Then area = 9, perimeter = 20
Height = 1, Width = 10 Then area = 10, perimeter = 22
Height = 2, Width = 1 Then area = 2, perimeter = 6
Height = 2, Width = 2 Then area = 4, perimeter = 8
Height = 2, Width = 3 Then area = 6, perimeter = 10
Height = 2, Width = 4 Then area = 8, perimeter = 12
Height = 2, Width = 5 Then area = 10, perimeter = 14
Height = 2, Width = 6 Then area = 12, perimeter = 16
Height = 2, Width = 7 Then area = 14, perimeter = 18
Height = 2, Width = 8 Then area = 16, perimeter = 20
Height = 2, Width = 9 Then area = 18, perimeter = 22
Height = 2, Width = 10 Then area = 20, perimeter = 24
Height = 3, Width = 1 Then area = 3, perimeter = 8
Height = 3, Width = 2 Then area = 6, perimeter = 10
Height = 3, Width = 3 Then area = 9, perimeter = 12
Height = 3, Width = 4 Then area = 12, perimeter = 14
Height = 3, Width = 5 Then area = 15, perimeter = 16
Height = 3, Width = 6 Then area = 18, perimeter = 18
Height = 3, Width = 7 Then area = 21, perimeter = 20
Height = 3, Width = 8 Then area = 24, perimeter = 22
Height = 3, Width = 9 Then area = 27, perimeter = 24
Height = 3, Width = 10 Then area = 30, perimeter = 26
Height = 4, Width = 1 Then area = 4, perimeter = 10
Height = 4, Width = 2 Then area = 8, perimeter = 12
Height = 4, Width = 3 Then area = 12, perimeter = 14
Height = 4, Width = 4 Then area = 16, perimeter = 16
Height = 4, Width = 5 Then area = 20, perimeter = 18
Height = 4, Width = 6 Then area = 24, perimeter = 20
Height = 4, Width = 7 Then area = 28, perimeter = 22
Height = 4, Width = 8 Then area = 32, perimeter = 24
Height = 4, Width = 9 Then area = 36, perimeter = 26
Height = 4, Width = 10 Then area = 40, perimeter = 28
Height = 5, Width = 1 Then area = 5, perimeter = 12
Height = 5, Width = 2 Then area = 10, perimeter = 14
Height = 5, Width = 3 Then area = 15, perimeter = 16
Height = 5, Width = 4 Then area = 20, perimeter = 18
Height = 5, Width = 5 Then area = 25, perimeter = 20
Height = 5, Width = 6 Then area = 30, perimeter = 22
Height = 5, Width = 7 Then area = 35, perimeter = 24
Height = 5, Width = 8 Then area = 40, perimeter = 26
Height = 5, Width = 9 Then area = 45, perimeter = 28
Height = 5, Width = 10 Then area = 50, perimeter = 30
Height = 6, Width = 1 Then area = 6, perimeter = 14
Height = 6, Width = 2 Then area = 12, perimeter = 16
Height = 6, Width = 3 Then area = 18, perimeter = 18
Height = 6, Width = 4 Then area = 24, perimeter = 20
Height = 6, Width = 5 Then area = 30, perimeter = 22
Height = 6, Width = 6 Then area = 36, perimeter = 24
Height = 6, Width = 7 Then area = 42, perimeter = 26
Height = 6, Width = 8 Then area = 48, perimeter = 28
Height = 6, Width = 9 Then area = 54, perimeter = 30
Height = 6, Width = 10 Then area = 60, perimeter = 32
Height = 7, Width = 1 Then area = 7, perimeter = 16
Height = 7, Width = 2 Then area = 14, perimeter = 18
Height = 7, Width = 3 Then area = 21, perimeter = 20
Height = 7, Width = 4 Then area = 28, perimeter = 22
Height = 7, Width = 5 Then area = 35, perimeter = 24
Height = 7, Width = 6 Then area = 42, perimeter = 26
Height = 7, Width = 7 Then area = 49, perimeter = 28
Height = 7, Width = 8 Then area = 56, perimeter = 30
Height = 7, Width = 9 Then area = 63, perimeter = 32
Height = 7, Width = 10 Then area = 70, perimeter = 34
Height = 8, Width = 1 Then area = 8, perimeter = 18
Height = 8, Width = 2 Then area = 16, perimeter = 20
Height = 8, Width = 3 Then area = 24, perimeter = 22
Height = 8, Width = 4 Then area = 32, perimeter = 24
Height = 8, Width = 5 Then area = 40, perimeter = 26
Height = 8, Width = 6 Then area = 48, perimeter = 28
Height = 8, Width = 7 Then area = 56, perimeter = 30
Height = 8, Width = 8 Then area = 64, perimeter = 32
Height = 8, Width = 9 Then area = 72, perimeter = 34
Height = 8, Width = 10 Then area = 80, perimeter = 36
Height = 9, Width = 1 Then area = 9, perimeter = 20
Height = 9, Width = 2 Then area = 18, perimeter = 22
Height = 9, Width = 3 Then area = 27, perimeter = 24
Height = 9, Width = 4 Then area = 36, perimeter = 26
Height = 9, Width = 5 Then area = 45, perimeter = 28
Height = 9, Width = 6 Then area = 54, perimeter = 30
Height = 9, Width = 7 Then area = 63, perimeter = 32
Height = 9, Width = 8 Then area = 72, perimeter = 34
Height = 9, Width = 9 Then area = 81, perimeter = 36
Height = 9, Width = 10 Then area = 90, perimeter = 38
Height = 10, Width = 1 Then area = 10, perimeter = 22
Height = 10, Width = 2 Then area = 20, perimeter = 24
Height = 10, Width = 3 Then area = 30, perimeter = 26
Height = 10, Width = 4 Then area = 40, perimeter = 28
Height = 10, Width = 5 Then area = 50, perimeter = 30
Height = 10, Width = 6 Then area = 60, perimeter = 32
Height = 10, Width = 7 Then area = 70, perimeter = 34
Height = 10, Width = 8 Then area = 80, perimeter = 36
Height = 10, Width = 9 Then area = 90, perimeter = 38
Height = 10, Width = 10 Then area = 100, perimeter = 40

Add a comment
Know the answer?
Add Answer to:
Java Write a program to print the perimeter and area of rectangles using all combinations of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java program that computes the total surface area of a rectangular prism. There are...

    Write a java program that computes the total surface area of a rectangular prism. There are six sides, so the area of all six sides has to the summed to get the total area. The program should ask the user to enter the length (L), width (W) and the height )H) for the object in inches. Create a separate method from the main to calculate the area (name the method calcArea). The output of calcArea will return a double. Output;...

  • Of all rectangles with area 100, which one has the minimum perimeter? Let P and w...

    Of all rectangles with area 100, which one has the minimum perimeter? Let P and w be the perimeter and width, respectively, of the rectangle. Write the objective function in terms of P and w. Assume that the width is less than the length if the dimensions are unequal. P= (Type an expression.) The interval of interest of the objective function is (Simplify your answer. Type your answer in interval notation.) Of all rectangles with area 100, the one with...

  • 1. Write a program that determines the area and perimeter of a square. Your program should...

    1. Write a program that determines the area and perimeter of a square. Your program should accept the appropriate measurement of the square as input from the user and display the result to the screen. Area of Square = L (squared) Perimeter of Square = 4 * L 2.  Write a program that determines the area and circumference of a circle. Your program should accept the appropriate measurement of the circle as input from the user and display the result to...

  • write a program in java to print all the powers of 2 below a certain number...

    write a program in java to print all the powers of 2 below a certain number and calculate their sum. Make sure your program conforms to the following requirements. 1. Accept the upper limit from the user (as an integer). 2. These numbers grow very fast. make sure the sum variable is of the "long" type. You can assume that the test output will be less that LONG MAX. 3.Print all numbers as a running sum, and finally print their...

  • Write a java program to print all the powers of 2 below a certain number and...

    Write a java program to print all the powers of 2 below a certain number and calculate their sum Requirements: 1. Accept the upper limit from the user as an integer 2. Make sure the sum variable is of the “long” type. You can assume that the test output will be less than LONG MAX. 3. Print all the numbers as a running sum, and finally print their sum. Please try and restrict yourself to loops, selection statements, and calls...

  • write a c programming Write a program that will calculate the perimeter, area and volume of...

    write a c programming Write a program that will calculate the perimeter, area and volume of a is is entered by the user. Your program will display the radius, perimeter, area and volume to the monitor and will also save them to a file called "circlePAV.txt". Your program should prompt the user for the radius until the user enters -1. Use the following structure. typedef struct ( float radius; float area, float perimeter; float volume; ylinder Figure>

  • Modify the C++ program you created in assignment 1 by using 'user defined' functions. You are...

    Modify the C++ program you created in assignment 1 by using 'user defined' functions. You are to create 3 functions: 1. A function to return the perimeter of a rectangle. This function shall be passed 2 parameters as doubles; the width and the length of the rectangle. Name this function and all parameters appropriately. This function shall return a value of type double, which is the perimeter. 2. A function to return the area of a rectangle. This function shall...

  • *JAVASCRIPT QUESTION* Write a JavaScript program that calculates the area and perimeter of a square. Use...

    *JAVASCRIPT QUESTION* Write a JavaScript program that calculates the area and perimeter of a square. Use document.write() for output.

  • (NEED FULL CODE PLEASE)write a java program class to calculate and display the areas of 10 rectan...

    (NEED FULL CODE PLEASE)write a java program class to calculate and display the areas of 10 rectangles using arrays. * input validation sizes must be between 0-50 inches output to be displayed on the screen and send to an output file. *the output must appear in the following format. rectangle length width area 1    2.0    3.0    6.0 2 - - - - 10 display the rectangle with largest area. rectangle1 area= display the rectangle with smallest area. rectangle2 area=

  • Write a program that collects the dimensions of two rectangles. For each rectangle, the program collects...

    Write a program that collects the dimensions of two rectangles. For each rectangle, the program collects the width and length. Then, the program should print one of the following messages depending on the relative values of the rectangle sizes: -          Rectangle 1 is bigger than Rectangle 2. -          Rectangle 1 is the same size as Rectangle 2. -          Rectangle 2 is bigger than Rectangle 1. For example, consider the sample output of the proposed program (the bold font represents user...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT