JAVA 7 ? 2;Designing and Implementing a Program Using Predefined, Value ? Returning Methods;In the following exercises, your answer questions to determine the design of a Java program. Each exercise may have several correct answers. The answers you choose will determine your program design.;Suppose a user wants to calculate the square of a number or the square root of a number, and display the results. To design this problem, what do you need to know about the predefined methods that have this purpose?;The user will also enter a character value to designate which process is wanted. Should you make any assumptions about the case of the character entered? Would thatrequire using any other predefined method?;What variables do you need for user input and for calculations? What types are these variables?;The program should process at least one number, and the user should be allowed to continue processing numbers until a value is entered to quit. What kind of loop works best in this situation?;Does the numeric value entered need any type of validation? Is that validation dependent on which math method is to be called?;What is the required data type and number of arguments required for the predefined methods you are using?;If the methods you are using are value returning, how will those returned values be handled?;Should your decimal numbers be formatted? If so, what method, from what class, is needed?;9a. Design the program to calculate either the square of anumber or the square root of a number and display the results.;Following is a copy of the screen results that might appear after running your program, depending on the data entered. The text entered by the user appears in bold.;Enter a float value: 6.2;Do you want the (s)quare or square (r)oot of 6.2: r;The the square root of 6.2 is 2.4899799195977463;Do you want to enter more data? y/n: y;Enter a float value: -4.6;Do you want the (s)quare or square (r)oot of -4.6: r;You must have a positive number for square root.;Do you want the(s)quare or square (r)oot of -4.6: s;You must have a positive number for square root.;The number -4.6 squared has the value 21.159999999999997;Do you want to enter more data? y/n: y;Enter a float value: 3.9;Do you want the(s)quare or square (r)oot of 3.9: s;The number 3.9 squared has the value 15.209999999999999;Do you want to enter more data? y/n: y;Enter a float value: -4;Do you want the (s)quare or square (r)oot of -4.0: s;The number -4.0 squared has the value 16.0;Do you want to enter more data? y/n: n;Write your design. Your design should be a list of Java comments without any code.;9b. Write a Java program based on the design you created in exercise 9a. For readability,insert blank lines to separate parts of the program. Include comments to explain the different sections of code. Save the program as SqrSqrt.java to the device or location specified by your instructor. Compile, execute, and test program. After executing your program, select and copy everything that appears on your screen. Paste the copied text into a comment at the end of your program.
Paper#69262 | Written in 18-Jul-2015Price : $37