Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(3 points) Identify the errors in the following programs. a) 3 errors public class Test { public static void main(String[] args) { System.out.println(method2(3.4)); }
(3 points) Identify the errors in the following programs. a) 3 errors public class Test { public static void main(String[] args) { System.out.println(method2(3.4)); } public static int method(int n) { if (n > 0) return 1; else if (n == 0) return 0; else if (n < 0) return -1; } } b) 2 errors public class Test { public static void main(String[] args) { } nPrintln(5, "Welcome to Java!"); public static void nPrintln(String message, int n) { for (int i = 0; i < n; i++) { System.out.println(message); } return n; } } 3) (7 points) Write a class called AveMethod that contains a main method and method called threeAve (method name) that computes the average of three numbers. NO CREDIT if a method is not used. a) The main method will do the following: asks the user for 3 number (double type). calls the threeAve method print the average of the three numbers b) The threeAve method will do the following: receives 3 numbers (parameters) calculate the average of the three numbers returns the average Sample Run: Input the first number: 2.5 Input the second number: 3.5 Input the third number: 6.6 The average is 4.2 Submission Copy and paste your code Screen shot the console with the same Sample Run as above 4) (8 points) Write a program called LoopMethod that contains a main method and a method called printNums that prints the numbers from a specified start to end value. NO CREDIT if a method is not used. a) The main method will do the following: asks the user for start and end number (int type). calls the printNums method b) The printNums method will do the following: receives start and end number (parameters) Sample Run: prints from the start to the end number using a loop Input start number: 3 Input end number: 9 3456789 Input start number: 9 Input end number: 21 9 10 11 12 13 14 15 16 17 18 19 20 21
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started