Question: In Java, Write a method with the following header to determine whether a given number is prime or not: Please answer each part of the
PartA Prime Sumbersl Write a method with the following header to determine whether a given number is a prime or not: public static beelean 4szime int au) Check the next page for an algorithm to complete this task. Use it to develop this method and test it After testing the method, write a program to list all prime numbers in the range of 2-1000. Submit PASa.java, PASaOut.doex via Blackboard. Part B Sum the digits in an integetlWrite a method with the following header that computes the sum of the digits of an integs public statie int sumDigits (int pum For example, suoDigita (2371) retums l 3 (which is the sum 2+3+7+1)-Use 96 operation to extract last digit, and / operation to remove the last digit (e.g. 2371 % 10 gives you 1, and 2371/10 gives you 237). Hint: one of the participation activity did this operation in a loop until all digits are extracted. Implement and test the method for various input values. Submit PA7b java, PA7bOut.docx for any 3 different sets of input values Submit source code and outputs via Blackboard. Part C Display barl Write a method using the following header to print a bar with a specified character public static void barDisplay (Int n, char cb) For example, call to the method: barDisplax10, "); produces Test this program inside a loop to generate rectangles, triangles of different shapes. ox (int j-l; j-:+) barDispluxj," would produce the following figure: toc(in 1 ; jes; j++) { barDispluts+1.@%) would produce the following figure: A@cea @444 4@a Experiment with various codes to generate other interesting shapes as well. Submit PA7e.java, PA7cOut.docx for any three different sets of shapes You may submit all three sets of submissions on Blackboard at one single time. t View Sec 1 Pages:1 of 2 Words: 0 of 654 L
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
