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 xxxxXxH1.java to generate 80 random integers from 200 ... 300 and print them 15 integers per line: java xxxxxH1 80 200 300 15

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
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
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("\n\n\tOOPS Invalid No. of aguments! EXIT.\n");
15 return;
16 }
17
18 // get values of n, a, b and k from program argument
19 n = Integer.parseInt(args[0]);
Integer.parseInt(args[1]);
20 a =
21 b =
Integer.parseInt(args[2]);
22 k = Integer.parseInt(args[3]);
23
24 //It's a good practice to print input in program output!
25 / formatted print
300 and
26 System.out.printf("\n\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("\n\n\tAuthor: Geo Date: %s\n",
33 java.time. LocalDate.now());
34} // end main
Transcribed Image Text: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 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("\n\n\tOOPS Invalid No. of aguments! EXIT.\n"); 15 return; 16 } 17 18 // get values of n, a, b and k from program argument 19 n = Integer.parseInt(args[0]); Integer.parseInt(args[1]); 20 a = 21 b = Integer.parseInt(args[2]); 22 k = Integer.parseInt(args[3]); 23 24 //It's a good practice to print input in program output! 25 / formatted print 300 and 26 System.out.printf("\n\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("\n\n\tAuthor: Geo Date: %s\n", 33 java.time. LocalDate.now()); 34} // end main
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY