Programming Assignment No. 5 Write a program that asks the user to enter a positive odd...

90.2K

Verified Solution

Question

Programming

Programming Assignment No. 5
Write a program that asks the user to enter a positive odd numberless than 20. If the number is 5, 11 or 15, draw a square whosewidth is the same as the number entered, if 3, 9, or 17, draw a box(a box is a hollowed out square) with the width the same as thenumber entered, otherwise just present an message saying \"To bedetermined\". Write a method for the square that accepts an integeras a parameter and returns a string (use for loops), the same forthe box( use while loops). No output should be done in thosemethods. Write a method that will ask for the number and does notreturn until the number entered satisfies the conditions above. Usea do while loop in that method. The method main cannot be used asone of the methods to be written. Use a switch statement todetermine which shape to draw. Use the methods from the IO classused in Program 4 for input and output. Modify showMessage so thatit uses a fixed-width font otherwise IO should be the same as forProgram 4. The main program should be in the default package. Goodprogram structure, adherarnce to Java conventions, and indentationare required. There will be 2 files for this assignmentProgram5.java which is the default package and IO.java which is inthe util package. IO.java will be the same as it was in Program 4.Do not write any more methods than the ones specified. The programabove is just a starting point, there are a number of changes thatneed to be made before. If you are not sure how to get started, amore detailed starting point is in the video.

Answer & Explanation Solved by verified expert
3.9 Ratings (596 Votes)
Problem5javaimport javautilScannerclass Problem5 public static void mainString args Get input from user int n getInput switchn Squarecase case 5    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students