Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please implement the code in java Specification: Write a program (AppleOrange, that lives in AppleOrange.java). This program should print the numbers from 1 to X

image text in transcribedPlease implement the code in java

Specification: Write a program (AppleOrange, that lives in AppleOrange.java). This program should print the numbers from 1 to X (inclusive), space separated, but for multiples of 3 print apple instead of the number, for multiples of 7 printorange" instead of the number, and for the multiples of both 3 and 7 print appleorange (no space) instead of the number. X is a command line argument to the program. Don't forget to document as you go. Example program run (coloring added for readability): > java AppleOrange 10 1 2 apple 4 5 apple orange 8 apple 10 > java AppleOrange 25 1 2 apple 4 5 apple orange 8 apple 10 11 apple 13 orange apple 16 17 apple 19 20 appleorange 22 23 apple 25 > java AppleOrange 50 1 2 apple 45 apple orange 8 apple 10 11 apple 13 orange apple 16 17 apple 19 20 appleorange 22 23 apple 25 26 apple orange 29 apple 31 32 apple 34 orange apple 37 38 apple 40 41 appleorange 43 44 apple 46 47 apple orange 50 Checking for Invalid Input Your program should print the following (exactly) if the command line argument is missing, if the argument is not a positive number, or if too many arguments are given. This message should be sent to System.err not System.out. Example commands which generate this error: > java AppleOrange > java AppleOrange 0 > java AppleOrange 1 1 > java AppleOrange apple

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

More Books

Students also viewed these Databases questions