I'm trying to find the best way to give "args" a input variable, it isn't working like how I want. These are the instructions my professor wants me to follow: write a program that takes two double command line arguments representing the sides of a rectangle The program should then call a void function that reports the area of the rectangle accurate to three decimal places public static void main(String args) {         Scanner scan = new Scanner(System.in);         System.out.println("Enter length and width of rectangle " + args);         args = scan.nextLine();                  for (int i=0; i < args.length; i++)         {             System.out.println(args[i]);         }                          Double area= Double.parseDouble (args[0]) * Double.parseDouble (args[1]);         System.out.println(" Area of rectangle is :" + String.format("%.3f", area));     } }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

I'm trying to find the best way to give "args" a input variable, it isn't working like how I want.

These are the instructions my professor wants me to follow: write a program that takes two double command line arguments representing the sides of a rectangle
The program should then call a void function that reports the area of the rectangle accurate to three decimal places

public static void main(String args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter length and width of rectangle " + args);
        args = scan.nextLine();
        
        for (int i=0; i < args.length; i++)
        {
            System.out.println(args[i]);
        }
                
        Double area= Double.parseDouble (args[0]) * Double.parseDouble (args[1]);
        System.out.println(" Area of rectangle is :" + String.format("%.3f", area));
    }

}

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Hiring Problem
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,