Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program xxxxxH1.java (where xxxxx is at most the 1st five characters of your last name) that gets 4 integers n, a, b

Write a java program xxxxxH1.java (where xxxxx is at most the 1st five characters of your last name) that gets 4 integers n, a, b and k from program argument and calls generate (n, a, b, k). Make sure to your generate method is private. Make sure to use formatted output. To compile: javac xxxxxH1.java Example to execute xxxxxH1.java to generate 80 random integers from 200 ... 300 and print them 15 integers per line: java xxxxxH1 80 200 300 15 Your main method should be as follow: 1 // main program gets input from program argument 2 public static void main(String args[]) throws Exception{ 3 // declare variables 4 int n, a, b, k, cnt; 5 6 //create an instance of a class 7 xxxxxH1 g = new xxxxxH1 (); 8 9 10 // get no. of arguments 11 cnt = args.length; 12 13 if (cnt < 4) { 14 System.out.printf(" \tOOPS Invalid No. of aguments! EXIT. "); 15 return; 16 } 17 18 // get values of n, a, b and k from program argument 19 n = Integer.parseInt(args[0]); 20 a = Integer.parseInt(args[1]); 21 b = Integer.parseInt(args[2]); 22 k = Integer.parseInt(args[3]); 23 24 //Its a good practice to print input in program output! 25 // formatted print 26 System.out.printf(" \tINPUT: n = %4d, a = %4d, b = %4d, k = %4d", n, a, b, k); 27 28 // Call generate Method 29 g.generate(n, a, b, k); 30 31 //Pleas replace Geo with your name in next line 32 System.out.printf(" \tAuthor: Geo Date: %s ", 33 java.time.LocalDate.now()); 34 } // end main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

LO6 List the components of job descriptions.

Answered: 1 week ago

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago